Repository navigation
fix(auth): SSO allow-list and OAuth state check - #495
Merged
Merged
Conversation
- auth.allowed_emails / auth.allowed_domains (env AUTH_ALLOWED_EMAILS, AUTH_ALLOWED_DOMAINS): with a list set, only a provider-verified email on the list, or in an allowed domain, gets a token; others get a 403 page. Domain = Google's hd claim for provider google, the verified email's domain for the rest. No list = as before (anyone the provider signs in), with a startup warning. - GitHub: verified primary email from /user/emails when the scope allows. - Login sets an HttpOnly SameSite=Lax state cookie; the callback refuses a missing or different state (login CSRF) and clears the cookie.
A list set after sign-in now also cuts sessions issued before it: the token carries email_verified and hd, and TokenStore applies the access policy in Validate (HTTP middleware) and ExpiresAt (WebSocket connect). Tokens without email_verified (issued before this change) fail a list.
Member
Author
|
Review fix c26ad45: the token now carries |
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.
Problem
handleCallbackissued a token to every user. WithAUTH_PROVIDER=googleon a public Ingress (e.g. the Helm chart), any Google account could sign in and read all events.statewas not checked. It was generated but never verified on the callback, so a forged callback link could log a victim into an attacker's account (login CSRF).Change
auth.allowed_emails/auth.allowed_domains(envAUTH_ALLOWED_EMAILS,AUTH_ALLOWED_DOMAINS, comma lists; documented inbuggregator.yaml.example). Auth has no CLI flags today, so these follow the otherauth.*settings: yaml + env.email_verified; GitHub: the verified primary email from/user/emails, falling back to the public profile email, which GitHub only allows from verified emails).hdclaim (the Workspace domain) forprovider: google, so a personal Google account with a company address does not pass; for other providers, the domain of the verified email.403HTML page naming the account, with a "sign in again" link; no token.HttpOnly,SameSite=Laxcookiebg_oauth_state(path/auth/sso, 10 min,Secureover HTTPS or behindX-Forwarded-Proto: https). The callback refuses a missing or different state with400and always clears the cookie.Verification
TestCallback_AllowListAndState(fake OIDC provider viahttptestand the realOAuthClient): no list, Googlehdallowed or denied, email domain withouthddenied for Google, listed email, OIDC email domain,email_verifiedas a string, unverified email denied, state mismatch, no state cookie. AlsoTestStateCookieSecureBehindHTTPSProxy,TestGitHubVerifiedEmail,TestEnvList.go vet ./...clean;go test -count=1 ./...green.AUTH_PROVIDER=google AUTH_ALLOWED_DOMAINS=acme.com. Workspaceann@acme.com→ redirect to/login?token=…. Personalbob@gmail.com→403"bob@gmail.com is not allowed to sign in…". Callback with a forged state and no cookie →400./api/eventswithout a token →401.Follow-up outside this repo: Helm chart values for the two new env vars.
Made with harnsy