Plugins
OAuth Provider
Turn Kernia into an OAuth 2.0 and OpenID Connect issuer.
The OAuth provider package lets your application issue authorization codes, access tokens, refresh tokens, and ID tokens to registered clients. Use it when third-party apps need to sign in with your Kernia users.
Installation
uv add kernia-oauth-providerImport path
from kernia_oauth_provider import OAuthProviderOptions, oauth_providerServer configuration
import os
from kernia import KerniaOptions
from kernia.auth import init
from kernia_oauth_provider import OAuthProviderOptions, oauth_provider
from .db import adapter
auth = init(KerniaOptions(
database=adapter,
secret=os.environ["KERNIA_SECRET"],
base_url=os.environ["KERNIA_BASE_URL"],
base_path="/api/auth",
plugins=(
oauth_provider(OAuthProviderOptions(issuer=os.environ["KERNIA_BASE_URL"])),
),
))API routes
GET
/api/auth/oauth2/authorizeValidates client and consent context, then issues an authorization code.
POST
/api/auth/oauth2/tokenExchanges authorization codes or refresh tokens for token responses.
GET
/api/auth/oauth2/userinfoReturns OIDC userinfo for an access token.
POST
/api/auth/oauth2/revokeRevokes a token.
POST
/api/auth/oauth2/introspectIntrospects token activity and metadata.
GET
/api/auth/.well-known/openid-configurationPublishes OIDC discovery metadata.
POST
/api/auth/oauth2/registerRegisters an OAuth client when dynamic registration is enabled.
Schema impact
Adds OAuth client, authorization code, token, and consent related models from the standalone package. Generate migrations before enabling clients.
Behavior and options
- Keep issuer, redirect URI validation, scopes, and client authentication strict.
- Use HTTPS issuer URLs outside local tests.
- Pair with the JWT/JWKS path for OIDC token verification.