Support multiple OIDC providers
kaya-oidc 0.0.6 can run several providers in one app (OIDCProviders), each with its own login route and namespaced session state. Adopt it: providers are configured in indexed, contiguous OIDC_<n>_* blocks (0-based) with OIDC_<n>_PROVIDER naming the provider in its login URL and session keys. The old unindexed OIDC_ISSUER/OIDC_CLIENT_ID/... names are no longer read; startup fails with a rename hint when they are set. With no OIDC variables at all, the single dev mock provider named "default" is used, as before. The platform now authenticates through OIDCProviders: auth.current_user returns the session's user (sessions stay single-identity, so at most one provider is logged in) and require_auth/route handlers use it, while the websocket path keeps scanning for any provider's user. New routes expose the configuration to the SPA and keep old links working: GET /api/auth/providers lists the login URLs, GET /auth/login redirects to the first provider and GET /auth/logout to whichever provider the session is logged in with. The lobby renders one login button per provider from that endpoint. Update the env examples, compose and k8s manifests to the indexed scheme, document the multiple-provider setup and the migration, and cover it with config, auth and route tests.
This commit is contained in:
+23
-6
@@ -13,12 +13,29 @@ DATABASE_OPTIONS=
|
||||
# test suite (sqlite://:memory:) and handy for managed-DB URLs.
|
||||
#DATABASE_URL=postgres://tavolo:password@localhost:5432/tavolo
|
||||
|
||||
# OIDC (mock-oauth2-server in dev; it does not validate clients, so any
|
||||
# client id/secret works. For a real IdP like Keycloak, use its values here.)
|
||||
OIDC_ISSUER=http://localhost:8180/tavolo
|
||||
OIDC_CLIENT_ID=tavolo
|
||||
OIDC_CLIENT_SECRET=dev-secret
|
||||
OIDC_REDIRECT_URI=http://localhost:8080/auth/callback
|
||||
# OIDC providers. Each provider is an indexed block: OIDC_<n>_PROVIDER
|
||||
# (required; names the provider in the login URL /auth/<provider>/login and
|
||||
# in its session state), OIDC_<n>_ISSUER, OIDC_<n>_CLIENT_ID,
|
||||
# OIDC_<n>_CLIENT_SECRET (optional: leave unset for public clients),
|
||||
# OIDC_<n>_REDIRECT_URI (defaults to
|
||||
# http://localhost:8080/auth/<provider>/callback), OIDC_<n>_POST_LOGIN_REDIRECT
|
||||
# and OIDC_<n>_POST_LOGOUT_REDIRECT (default /). Indices must be contiguous
|
||||
# from 0; add a second provider with an OIDC_1_* block (and so on).
|
||||
#
|
||||
# The values below target the dev mock-oauth2-server (it does not validate
|
||||
# clients, so any client id/secret works). For a real IdP like Keycloak,
|
||||
# use its values and register the redirect URI there.
|
||||
OIDC_0_PROVIDER=default
|
||||
OIDC_0_ISSUER=http://localhost:8180/tavolo
|
||||
OIDC_0_CLIENT_ID=tavolo
|
||||
OIDC_0_CLIENT_SECRET=dev-secret
|
||||
OIDC_0_REDIRECT_URI=http://localhost:8080/auth/default/callback
|
||||
# A second provider, e.g. Google:
|
||||
#OIDC_1_PROVIDER=google
|
||||
#OIDC_1_ISSUER=https://accounts.google.com
|
||||
#OIDC_1_CLIENT_ID=...
|
||||
#OIDC_1_CLIENT_SECRET=...
|
||||
#OIDC_1_REDIRECT_URI=http://localhost:8080/auth/google/callback
|
||||
|
||||
# Redis (session and live-game storage). Unset to fall back to in-memory
|
||||
# stores (only sensible for local development with a single worker).
|
||||
|
||||
Reference in New Issue
Block a user