feat: multi-idp authentication#204
Conversation
This commit introduces backend support for Multi-Identity Provider (Multi-IDP) authentication according to ADR-008.
Key changes:
1. **Configuration**: Updated `ConfigProvider` to parse `OIDC_PROVIDER_<NAME>_<PROPERTY>` prefix-based environment variables, replacing the singular `oidcConfig` with an `oidcProviders` Map.
2. **OIDC Discovery**: Modified `OidcBootstrapService` to concurrently fetch discovery documents for all configured IDPs on application startup.
3. **Database**:
* Added a `provider_id` column to the `pkce_sessions` table.
* Created a new `user_identities` table with a `UserIdentityRepository` to store identity links mapping providers and OIDC subjects to users.
4. **Auth Service**:
* Updated login initiation to accept a `provider` ID.
* Enforces the `email_verified: true` security constraint for Day-1 multi-IDP authentication.
* Creates a `UserIdentity` link on initial user auto-registration.
* Returns an `auth_identity_conflict` error if a user attempts to log in with an email matching an existing account but without a corresponding provider identity link.
5. **Controllers**:
* Added `AuthProvidersController` exposing `GET /auth/providers` to list available IDPs to the frontend.
* Updated `WebAuthController` and `CliAuthController` to handle the `provider` parameter.
Co-authored-by: giovannibaratta <11740915+giovannibaratta@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR implements backend support for Multi-Identity Provider (Multi-IDP) authentication, resolving ADR-008. It allows Approvio to connect to multiple IDPs (like Google Workspace, Okta) simultaneously.
Changes include schema updates to track user identities per provider, PKCE session updates to store the initiating provider, ConfigProvider updates to read multi-IDP configurations from environment variables, and new API endpoints (
GET /auth/providers) to surface available login options to clients. It also introduces Day-1 security measures, rejecting users with unverified emails and preventing cross-provider auto-linking if an identity conflict arises.PR created automatically by Jules for task 8056947457823396443 started by @giovannibaratta