Commit graph

8 commits

Author SHA1 Message Date
Denis Arnst
a6848065e1
OIDC: Skip nonce for mobile flow to fix app login
Some IdPs (e.g. Authentik) don't echo the nonce in the id_token for
the authorization code flow, causing "nonce mismatch, got: undefined"
errors when the mobile app attempts SSO login. The mobile flow already
uses PKCE which provides equivalent replay protection, so nonce is not
needed. Web flow continues to use nonce for defense-in-depth.
2026-02-13 12:35:03 +01:00
Denis Arnst
67f8eb6815
OIDC: Support object-shaped and string group claims
The group claim was assumed to always be an array, which crashes with
providers like Zitadel that return an object with role names as keys
(e.g. { "admin": {...}, "user": {...} }). Normalize all common formats:
array, single string, and object (extract keys).

Fixes #4744
2026-02-12 13:25:56 +01:00
Denis Arnst
e428ba5657
OIDC: Fix CodeQL warnings 2026-02-05 20:31:07 +01:00
Denis Arnst
49aeb2da19
Require email_verified to be explicitly true when enforcement is enabled
Previously the check only rejected email_verified === false, allowing
logins when the claim was missing entirely. Since the admin opted in,
the IdP is expected to provide the claim.
2026-02-05 19:56:58 +01:00
Denis Arnst
d5047978a8
Add unit tests for OIDC callback flow and authorization
Test handleCallback (11), getAuthorizationUrl (13), generatePkce (5),
handleMobileRedirect (5), cleanupStaleAuthSessions (3). 88 total.
2026-02-05 19:35:50 +01:00
Denis Arnst
ed0db539c9
Add unit tests for 5 OidcAuthStrategy methods
Cover validateGroupClaim, isValidRedirectUri, isValidWebCallbackUrl,
updateUserPermissions, and verifyUser with 40 new tests (51 total).

Tests cover open redirect prevention, group claim validation,
auto-registration flows, permission updates, and error handling.
2026-02-05 18:04:14 +01:00
Denis Arnst
073eff74ef
Add OIDC Back-Channel Logout support
Implement OIDC Back-Channel Logout 1.0 (RFC). When enabled, the IdP can
POST a signed logout_token JWT to invalidate user sessions server-side.

- Add BackchannelLogoutHandler: JWT verification via jose, jti replay
  protection with bounded cache, session destruction by sub or sid
- Add oidcSessionId column to sessions table with index for fast lookups
- Add backchannel logout route (POST /auth/openid/backchannel-logout)
- Notify connected clients via socket to redirect to login page
- Add authOpenIDBackchannelLogoutEnabled toggle in schema-driven settings UI
- Migration v2.34.0 adds oidcSessionId column and index
- Polish settings UI: auto-populate loading state, subfolder dropdown
  options, KeyValueEditor fixes, localized descriptions via descriptionKey,
  duplicate key detection, success/error toasts
- Localize backchannel logout toast (ToastSessionEndedByProvider)
- OidcAuthStrategy tests now use real class via require-cache stubbing
2026-02-05 17:55:10 +01:00
Denis Arnst
33bee70a12
Revamp OIDC auth: remove Passport wrapper, add schema-driven settings UI
- Remove Passport.js wrapper from OIDC auth, use openid-client directly
- Add schema-driven OIDC settings UI (OidcSettingsSchema.js drives form rendering)
- Add group mapping with KeyValueEditor (explicit mapping or legacy direct name match)
- Add scopes configuration (authOpenIDScopes)
- Add verified email enforcement option (authOpenIDRequireVerifiedEmail)
- Fix group claim validation rejecting URN-style claims (#4744)
- Add auto-discover endpoint for OIDC provider configuration
- Store oidcIdToken in sessions table instead of cookie
- Add AuthError class for structured error handling in auth flows
- Migration v2.33.0 adds oidcIdToken column and new settings fields
2026-02-05 17:54:59 +01:00