fix: support client aliases for subdomain email accounts#523
Open
DrBaher wants to merge 1 commit intosteipete:mainfrom
Open
fix: support client aliases for subdomain email accounts#523DrBaher wants to merge 1 commit intosteipete:mainfrom
DrBaher wants to merge 1 commit intosteipete:mainfrom
Conversation
When gog is configured with a client alias (e.g. 'company.ai') for an account whose email has a subdomain (e.g. user@sub.company.ai), auth and token resolution would fail because: 1. auth add: the email match check compared the OAuth-authorized email against the alias name, which never matched, aborting before saving the token. 2. ResolveClientForAccount: a bare string with no '@' was treated as an email with no domain, falling through to DefaultClientName instead of being used as the client name directly. Fix: - In auth_add.go: skip the email match check when c.Email has no '@', as the caller is intentionally using a client alias. - In clients.go: treat any input without '@' as a direct client name rather than attempting email/domain parsing. This allows workflows like: gog auth add company.ai --services gmail,... # sign in as user@sub.company.ai gog gmail search ... --account user@sub.company.ai # works via account_clients config Fixes auth for Workspace accounts on subdomain domains (e.g. medicus.ai).
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
When using
gog auth addwith a client alias for an account whose email has a subdomain (e.g.user@sub.company.ai), auth fails with:This affects any Google Workspace account on a subdomain domain (e.g.
baher@medicus.aiusing client aliasbaher.ai). Two bugs combine to cause this:auth_add.go: The OAuth-authorized email is compared against the alias name, which never matches a bare client name, so the token is never saved.clients.go:ResolveClientForAccounttreats any input without@as a malformed email with no domain, falling through toDefaultClientNameinstead of treating it as a direct client name.Fix
auth_add.go: Skip the email match check whenc.Emailhas no@— the caller is intentionally using a client alias, not an email address.clients.go: Treat any input without@as a direct client name rather than attempting email/domain parsing.Usage after fix
Tests
Added two new test cases:
TestAuthAddCmd_ClientAliasSkipsEmailCheck— verifies auth succeeds when a client alias is passedResolveClientForAccount/client name without @ is used as-is— verifies bare client name is returned directlyResolveClientForAccount/subdomain email routes via account_clients mapping— verifies subdomain email routing via configAll existing tests pass.