feat: support GOG_SA_KEY_PATH env var for explicit SA key file path#4
Merged
delight-ai-agent merged 4 commits intomainfrom Mar 5, 2026
Merged
feat: support GOG_SA_KEY_PATH env var for explicit SA key file path#4delight-ai-agent merged 4 commits intomainfrom
delight-ai-agent merged 4 commits intomainfrom
Conversation
When GOG_SA_KEY_PATH is set, tokenSourceForServiceAccountScopes reads the SA key from the specified path instead of deriving it from the account email. This decouples the account email (used as the DWD impersonation subject) from the key file location, enabling proxy wrappers to pass a user email as the account while pointing to a single SA key file. ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
carrotRakko
approved these changes
Mar 5, 2026
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.
Summary
When using a Service Account with Domain-Wide Delegation (DWD), the account email (used as the impersonation subject) differs from the SA's own identity. Currently,
tokenSourceForServiceAccountScopesderives the SA key file path from the account email, so the SA key must be placed at a path matching the impersonated user's email — requiring duplicate copies for each user.This adds support for a
GOG_SA_KEY_PATHenvironment variable that lets callers specify the SA key file path directly, decoupling the account email from the key file location.Changes
internal/googleapi/service_account.go: CheckGOG_SA_KEY_PATHat the top oftokenSourceForServiceAccountScopes; if set, read the key from that path and skip email-based path derivationinternal/googleapi/service_account_test.go: Add tests for the new env var (success + file-not-found)Use case
A proxy wrapper manages SA credentials centrally and passes the target user email as the account. With
GOG_SA_KEY_PATH, the proxy can point to a single SA key file while the account email flows through as the DWD subject:Without this, the proxy would need to place copies of the same SA key at
sa-{base64(user1)}.json,sa-{base64(user2)}.json, etc.✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)