Repository navigation
External login providers (OpenID Connect) - #236
Merged
Merged
Conversation
…apter, login routes
…sions, Sets, batch reorder)
Member
Author
|
Fixed all 9 SonarCloud findings in 28d5743:
c7c117e restores 4 unrelated files that a Prettier run had reformatted in 28d5743. Generated by Claude Code |
|
5 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Server side of external sign-in with OpenID Connect providers (Google, Microsoft, Keycloak, Okta, institutional SSO), alongside email/password login. Plan:
docs/superpowers/plans/2026-11-17-oidc-authentication.mdin openforis/arena#4748 (Tasks 1–3, see its "Implementation notes"). The Arena UI (login buttons, "Login providers" admin page, sign-in methods in the profile) comes in a follow-up Arena PR that uses this version.Database
Migration addingauth_provider(provider settings inprops, encrypted client secret, uploaded icon) anduser_external_identity(links a user to a provider account by(issuer, subject), cascade on user deletion).Providers:
AuthProviderService(ServerServiceType.authProvider)AUTH_PROVIDER_SECRET_ENCRYPTION_KEY.AUTH_PROVIDERS_CONFIG, a JSON file or inline JSON, with the secrets inAUTH_PROVIDER_<ID>_CLIENT_SECRET.getUserIdentities, andunlinkUserIdentity, which refuses to remove the user's last sign-in method.OpenID Connect adapter
openid-clientv6: discovery, PKCE (S256), state and nonce, ID token validation.openid-clienthandles the Microsoft multi-tenant issuer.AuthProviderAdapterinterface allows non-OIDC providers to be added later.Matching provider accounts to Arena users
Routes
GET /auth/providersand/auth/providers/:id/icon: public.GET /auth/oidc/:id: starts the sign-in.GET /auth/oidc/:id/callback.POST /auth/oidc/_2fa: Arena 2FA after the provider sign-in, when the provider requires it (the default) and the user has 2FA enabled. Uses the login rate limiters.POST /auth/oidc/:id/ticket: short-lived ticket for the link and test modes, requested by the logged-in user.GET /auth/oidc/_test-result: system admins only.httpOnly,SameSite=Laxcookies scoped to/auth/oidc./app/...returnTo. Tokens and claims never go in URLs.createSessionTokenswas extracted from the password login, so both logins create the same tokens and refresh cookie.Configuration
ARENA_PUBLIC_URL(for the redirect URIs),AUTH_PROVIDER_SECRET_ENCRYPTION_KEYandAUTH_PROVIDERS_CONFIG, documented in.env.template.Types of changes
New dependency
openid-client; new dev dependencyoauth2-mock-server.How has this been tested
yarn testagainst PostgreSQL 16 + PostGIS: 19 suites, 122 tests passed.yarn tsc,yarn lintandyarn buildare clean. New tests:oauth2-mock-server, started in a child process (it is ESM only):AUTH_PROVIDERS_CONFIGparsing.The compiled package was also loaded with plain Node (outside Jest) to check
require('openid-client').Do you consider this PR needs further testing?
Still to try: a sign-in with real Google, Microsoft and Keycloak providers, in a deployment with
ARENA_PUBLIC_URLset. This happens with the Arena PR that adds the UI.Disclaimer
openid-clientv6 is ESM only and this package compiles to CommonJS. It is loaded withrequire(supported by Node.js 22+) plus a type-only import withresolution-mode: 'import'. Jest transforms it, as it doesotplib.user_external_identity.provider_idhas no foreign key toauth_provider, because providers fromAUTH_PROVIDERS_CONFIGhave no row there. Deleting a provider deletes its links in the same transaction.yarn dbmigrate:create) failed under ts-node in my environment, so the migration files were written from the existing template.