feat(auth): read email from the userinfo endpoint when the access token has none #139
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!139
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/oidc-userinfo-email"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Zitadel's JWT access tokens carry no
emailoremail_verified, but KWS authorises the bootstrap Super Admin and staff/organization invitations only on a verified email read from the token. Against a real Zitadel the first admin signed in and got no role.OIDCVerifier.Verifynow asks the issuer's userinfo endpoint when the token has noemail:submust equal the token'ssub(elseErrInvalidToken)openidscope) isErrInvalidToken, i.e. a 401 so the web client signs the user out; any other failure isErrUnavailable(503) and is not cached, so a blank email never overwrites a stored oneAlso:
x/oauth2is now a direct dependency;authtestgained an opt-in userinfo endpoint; CLAUDE.md auth conventions updated. Needed IdP settings: the app issues JWT access tokens and the web apps request theemailscope.Checked
make cover91.6% total (min 80%),internal/auth96.3%.make lint0 issues; auth, app, rbac, contract tests pass with-race.Review
Dual-pass (Ponytail complexity, then correctness reviewer). Pass 2 said "fix first" with two Important findings (401 reported as 503; unverified answer cached 5 min). Both fixed with tests, plus per-subject cache, name-precedence and short-TTL tests; Pass 1 re-check clear.
Not done / risks
prompt=create, a real invitation.🤖 Generated with Claude Code