fix(google): allow "*" wildcard in hostedDomains to accept any hd claim#4821
Open
Shivam-nagar23 wants to merge 1 commit into
Open
fix(google): allow "*" wildcard in hostedDomains to accept any hd claim#4821Shivam-nagar23 wants to merge 1 commit into
Shivam-nagar23 wants to merge 1 commit into
Conversation
When the Google connector is configured with hostedDomains: ["*"], the LoginURL already passes hd=* to Google to require a Workspace account, but the post-token claim check at createIdentity rejected the login with "oidc: unexpected hd claim <domain>" because the equality match in the loop never matched the literal "*" against a real domain. Extract the validation into a small matchHostedDomain helper and treat "*" as a wildcard that accepts any non-empty hd claim. This lets operators require any Workspace domain (i.e. block personal @gmail.com accounts) without enumerating every domain in config. Add unit tests covering exact match, wildcard, mixed wildcard + explicit entries, and the empty-claim case (wildcard does not accept an empty hd). Signed-off-by: Shivam-nagar23 <shivam@devtron.ai>
Author
|
can any of the maintainers look at this please @sagikazarmark @lstoll @vito @fajran @SEJeff @ |
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.
Overview
Allow
"*"as a wildcard entry in the Google connector'shostedDomainsconfig so that any non-emptyhdclaim is accepted. This brings the post-token claim check in line with the existingLoginURLbehavior, which already passeshd=*to Google.What this PR does / why we need it
When
hostedDomains: ["*"]is configured,LoginURLcorrectly setshd=*on the Google auth URL, which tells Google to restrict the picker to Workspace (hosted) accounts. However the post-token validation increateIdentitydid a strict equality check betweenclaims.HostedDomainand each configured entry, so the wildcard never matched a real domain and login failed with:This is a common ask for multi-tenant Workspace deployments where the operator wants to allow any corporate Google account (i.e. block personal
@gmail.com) without enumerating every domain.Changes:
matchHostedDomain(claim, allowed)helper."*"entry as a wildcard that accepts any non-emptyhdclaim. An emptyhd(personal Gmail) is still rejected when*is configured — that's the intent.hd, wildcard alongside explicit domains, wildcard rejecting emptyhd, and empty claim with explicit domains.Special notes for your reviewer
hostedDomainsis already[]string; this just makes"*"a meaningful value end-to-end."*"was never a validhdclaim value, so the new branch only fires for operators who explicitly opt in.LoginURLlogic already uses"*"as the wildcard when multiple domains are configured (connector/google/google.goline ~180), so this PR makes the two sides of the validation consistent.Does this PR introduce a user-facing change?