Repository navigation
Description
Problem
Apps on the internal Cognito pool (e.g. cupcake/frosting) sign users in through the GoogleSAML identity provider, a Google Workspace SAML app. If the user's browser has a different Google account active, such as a personal Gmail, Google uses that account for the SAML request and returns:
403 — Error: app_not_configured_for_user
Google's error page has no way to switch accounts, so the user is stuck. The only workaround is signing out of Google, or using a private window.
Why it can't be fixed in the Cognito console
- SAML has no "choose an account" parameter. Google always uses the active session.
- Cognito's
prompt=select_accounton/oauth2/authorizeis forwarded to IdPs only on managed login, not the classic hosted UI (docs). The internal pool doesn't setmanaged_login_version, so it should be on classic (to confirm: Cognito → User pool → Domain → Branding version). - The docs describe forwarding
promptas an addition to the IdP's redirect URL, i.e. for OIDC/social providers. I found nothing documenting that Cognito maps it to SAMLForceAuthn. Even if it did, Google would re-ask the password for the same account rather than offer a choice.
Proposal: use the Google OIDC provider for the internal pool
terraform/platform/identity/main.tf already defines aws_cognito_identity_provider.internal_google, but it isn't created because google_client_id is empty. Google's OAuth endpoint supports what we need:
prompt=select_accountalways shows the account chooser, including "Use another account".hd=java.no, already inauthorize_url, narrows the chooser to java.no accounts.
Steps:
- Create the OAuth client in GCP project
javabin-platform, followingdocs/cognito-google-setup.md§1, and setgoogle_client_id/google_client_secret. - Add
prompt=select_accountto the provider'sauthorize_url, next tohd=. That works on the classic hosted UI. Moving the pool to managed login, so apps can passpromptthemselves, is an alternative. - Add
Googleto app clients'SupportedIdentityProviders.app_auth_syncalready includes every IdP on the pool, so this may only need a resync. Decide whetherGoogleSAMLstays as well or is removed. - Enforce the domain server-side.
hd=is only a UI hint (see the existing TODO). Check thatauth_claimsrejects non-java.no users, or add a check that does.
Things to check before switching
- User identities: OIDC users get a new Cognito identity (
username = sub), not linked to their existingGoogleSAMLuser. Check whether anything depends on the Cognito username orsubstaying the same, and whether the old SAML users should be linked or cleaned up. - Login page: if both IdPs are enabled, the hosted UI shows two buttons. Apps can skip that page by passing
identity_provider=Googleon/oauth2/authorize.
Done when
A user whose browser is signed in to a personal Gmail (and possibly a java.no account too) is shown Google's account chooser at login, picks their java.no account, and is signed in to the app.
Activity
fix(identity): refuse user-admin scope on internal clients and alert …
feat(auth): gated Google OIDC IdP, auth-status, URL validation and au…
fix(identity): lock down the internal Cognito pool (#166)
feat(auth): gated Google OIDC IdP, auth-status, URL validation and au…
feat(auth): gated Google OIDC IdP, auth-status, URL validation and au…
feat(identity): managed-login branding per app client and prompt=sele…
feat(identity): switch the internal pool domain to managed login (#173)
feat(identity): cut the internal pool over from GoogleSAML to Google (#…