Metadata-Version: 2.4
Name: kernia
Version: 0.1.0
Summary: Framework-agnostic authentication for Python: sessions, OAuth, passkeys, and a plugin system
Project-URL: Homepage, https://kernia.dev
Project-URL: Documentation, https://kernia.dev/docs
Project-URL: Source, https://github.com/advantch/kernia
Project-URL: Issues, https://github.com/advantch/kernia/issues
Project-URL: Changelog, https://github.com/advantch/kernia/releases
Author: Advantch
License-Expression: MIT
License-File: LICENSE
Keywords: asgi,authentication,authorization,django,fastapi,oauth,passkeys,security,sessions,sso,starlette
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: Session
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: argon2-cffi>=23
Requires-Dist: cryptography>=42
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2
Provides-Extra: all
Requires-Dist: aiosqlite>=0.20; extra == 'all'
Requires-Dist: anyio>=4.0; extra == 'all'
Requires-Dist: authlib>=1.3; extra == 'all'
Requires-Dist: django>=4.2; extra == 'all'
Requires-Dist: fastapi>=0.110; extra == 'all'
Requires-Dist: fastmcp>=2.3; extra == 'all'
Requires-Dist: greenlet>=3.0; extra == 'all'
Requires-Dist: motor>=3; extra == 'all'
Requires-Dist: python3-saml>=1.16; extra == 'all'
Requires-Dist: redis>=5; extra == 'all'
Requires-Dist: sqlalchemy>=2.0; extra == 'all'
Requires-Dist: starlette>=0.37; extra == 'all'
Requires-Dist: stripe>=10; extra == 'all'
Requires-Dist: webauthn>=2; extra == 'all'
Provides-Extra: django
Requires-Dist: anyio>=4; extra == 'django'
Requires-Dist: django>=4.2; extra == 'django'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.110; extra == 'fastapi'
Provides-Extra: jwt
Requires-Dist: authlib>=1.3; extra == 'jwt'
Provides-Extra: mcp
Requires-Dist: fastmcp>=2.3; extra == 'mcp'
Provides-Extra: mongo
Requires-Dist: motor>=3; extra == 'mongo'
Provides-Extra: oauth-provider
Requires-Dist: authlib>=1.3; extra == 'oauth-provider'
Provides-Extra: passkey
Requires-Dist: webauthn>=2; extra == 'passkey'
Provides-Extra: redis
Requires-Dist: redis>=5; extra == 'redis'
Provides-Extra: sqlalchemy
Requires-Dist: aiosqlite>=0.20; extra == 'sqlalchemy'
Requires-Dist: greenlet>=3.0; extra == 'sqlalchemy'
Requires-Dist: sqlalchemy>=2.0; extra == 'sqlalchemy'
Provides-Extra: sso
Requires-Dist: anyio>=4.0; extra == 'sso'
Requires-Dist: authlib>=1.3; extra == 'sso'
Requires-Dist: python3-saml>=1.16; extra == 'sso'
Provides-Extra: starlette
Requires-Dist: starlette>=0.37; extra == 'starlette'
Provides-Extra: stripe
Requires-Dist: stripe>=10; extra == 'stripe'
Description-Content-Type: text/markdown

# kernia

Framework-agnostic authentication core for Python: email/password, sessions, OAuth, and a plugin system. Wire-compatible with the official Better Auth JavaScript client, so an existing frontend can talk to a Kernia server unchanged.

Kernia is a framework-agnostic authentication library for Python. See [kernia.dev](https://kernia.dev).

## Features

- Email/password sign-up and sign-in with Argon2id hashing
- HMAC-signed session cookies and CSRF/trusted-origins protection
- OAuth 2.0 social sign-in with 35 built-in providers plus generic OAuth
- A plugin system: organizations, admin, magic links, email OTP, two-factor, JWT, OpenAPI, and more
- One schema across memory, SQLAlchemy, and MongoDB adapters
- Wire-compatible with the official Better Auth JavaScript client

## Installation

    pip install kernia

Adapters, server integrations, and optional plugins ship in the same
distribution as extras. Install only what you use:

    pip install "kernia[fastapi,sqlalchemy]"

Available extras: `jwt`, `passkey`, `sso`, `oauth-provider`, `stripe`, `mcp`,
`sqlalchemy`, `mongo`, `redis`, `fastapi`, `starlette`, `django`, and `all`. Each
pulls in its own third-party requirements; the import paths are unchanged
(`from kernia_fastapi import mount_kernia`, `from kernia_sqlalchemy import
sqlalchemy_adapter`, and so on).

## Usage

```python
import os
from kernia.auth import init
from kernia.plugins import email_and_password
from kernia.plugins.organization import organization
from kernia.types.init_options import KerniaOptions
from kernia_memory_adapter import memory_adapter

auth = init(
    KerniaOptions(
        database=memory_adapter(),
        secret=os.environ["KERNIA_SECRET"],
        base_url="http://localhost:8000",
        base_path="/api/auth",
        plugins=[email_and_password(), organization()],
    )
)
```

Mount it on a FastAPI app with `kernia-fastapi`:

```python
from fastapi import Depends, FastAPI
from kernia_fastapi import mount_kernia, require_session

app = FastAPI()
mount_kernia(app, auth)  # serves /api/auth/*

@app.get("/me")
async def me(session=Depends(require_session)):
    return {"user_id": session.user_id}
```

Point the official Better Auth JavaScript client at `/api/auth` and it works without a shim.

## Documentation

Full documentation at [kernia.dev/docs](https://kernia.dev/docs). Source at [github.com/advantch/kernia](https://github.com/advantch/kernia).

## License

MIT
