Skip to content

fix(auth): GitHub scopes, name before login, Entra verified email - #496

Merged
butschster merged 2 commits into
masterfrom
fix/sso-provider-claims
Nov 22, 2026
Merged

butschster merged 2 commits into
masterfrom
fix/sso-provider-claims

Conversation

@butschster

Copy link
Copy Markdown
Member

Problem

Found in the live SSO check (Keycloak, Dex, Authentik):

  1. GitHub: the default AUTH_SCOPES=openid,email,profile are not GitHub scopes. /user/emails is refused, so a user with a hidden email has no email and an allow-list refuses them.
  2. Name: the profile shows the login (preferred_username / nickname) even when the provider sends a full name: Keycloak shows ann, not «Ann Acme».
  3. Microsoft Entra: sends no email_verified, so with an allow-list nobody gets in.

Change

  • auth.DefaultScopes(provider): read:user,user:email for github, openid,email,profile for the others; used when AUTH_SCOPES is not set. buggregator.yaml.example no longer hard-codes the OIDC default in ${AUTH_SCOPES:…}.
  • Name order: name, then preferred_username, nickname, login (GitHub: name, then login).
  • Entra, following Microsoft's guidance not to trust email alone: the ID token returned by the token endpoint is read for what userinfo lacks: email_verified, hd, and Entra's optional claim xms_edov (the tenant verified the email's domain). With xms_edov true the email counts as verified. Without it, behaviour is as before: the allow-list refuses, fail-closed. The admin adds xms_edov under App registration → Token configuration → Optional claims → ID.
    • The ID token is not signature-checked. It comes straight from the token endpoint over TLS, which OIDC Core 3.1.3.7 accepts. We still require aud = client ID, iss = discovery issuer and sub = userinfo sub; a token that fails any of these is ignored.
    • Userinfo stays the main source: an explicit email_verified: false there is not overridden.

Verification

  • TestExchange_IDTokenClaims: Entra with/without xms_edov (bool and "1"), no ID token, wrong audience/issuer/subject ignored, email_verified + hd from the ID token, userinfo false kept; each case also through the allow-list. TestMapUser_NameBeforeLogin, TestDefaultScopes.
  • go vet ./... clean; go test -count=1 ./... green.
  • Live with Keycloak 26.0 (real ID token): ann → signed in, profile name «Ann Acme»; bob (other domain) and eve (unverified email) → 403.
  • Not live: GitHub and Entra (no OAuth apps yet; tracked on the live-check item).

Made with harnsy

- Default scopes for provider github are read:user,user:email (GitHub is
  not OIDC); others keep openid,email,profile.
- Profile name prefers the full name, then the login.
- ID token from the token endpoint fills what userinfo lacks:
  email_verified, hd, and Entra's xms_edov (verified email domain).
  Checked: audience = client ID, issuer = discovery issuer, sub = userinfo
  sub; otherwise ignored.
@butschster butschster added the type: bug Something is broken or behaves incorrectly label Nov 22, 2026
@butschster
butschster merged commit 8ddac87 into master Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant