Skip to content

feat(auth): support pure service account mode without impersonation#1

Merged
delight-ai-agent merged 1 commit intomainfrom
feat/sa-pure-mode
Mar 3, 2026
Merged

feat(auth): support pure service account mode without impersonation#1
delight-ai-agent merged 1 commit intomainfrom
feat/sa-pure-mode

Conversation

@delight-ai-agent
Copy link
Member

Summary

Mirrors upstream PR steipete#399.

When a service account is configured via gog auth service-account set, the CLI always sets cfg.Subject (the JWT sub claim), which triggers Domain-Wide Delegation. This makes it impossible to use a service account in "pure" mode — where it accesses only resources explicitly shared with its own email address.

This PR skips setting cfg.Subject when the provided subject matches the service account's own client_email. This enables a common automation pattern: share a Drive folder or Calendar with the SA email, and access only those resources — no DWD required.

Changes

  • internal/googleapi/service_account.go — guard cfg.Subject assignment: only set when subject differs from the SA's client_email
  • internal/googleapi/service_account_test.go — 3 test cases: pure SA mode, impersonation mode, empty subject

Test plan

  • go test ./internal/googleapi/ — all existing + new tests pass
  • go build ./... — compiles cleanly

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)

Skip setting cfg.Subject when the subject matches the service account's
own client_email.  This lets a service account access only resources
explicitly shared with it, without requiring Domain-Wide Delegation.

Closes steipete#346

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
@delight-ai-agent delight-ai-agent merged commit 2587cd7 into main Mar 3, 2026
1 of 4 checks passed
@delight-ai-agent delight-ai-agent deleted the feat/sa-pure-mode branch March 3, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants