Repository navigation
Description
What happens
Since #6908 (v0.57.0, for #6900) the auth server records the verified upstream identity (session.UpstreamSubject:
issuer, subject, stable claim and value) as VerifiedUpstream on every login. It does this whether or not
SubjectIdentifierAudiences is set. The value then gets persisted in plaintext in:
- the pending device confirmation and the device request (
device_verification.go:287,:376) - the authorize code, PKCE, access and refresh token sessions (
callback.go:543,deviceflow/handler.go:148) - the next leg's pending authorization in multi-upstream chains (
callback.go:881)
The only reader is handlers/token.go:135-159. It turns the value into the sub_id and upstream subject
claims, but only for audiences listed in SubjectIdentifierAudiences. With that list empty, which is the
default, every one of those writes is stored data nobody reads.
Why it matters
It's a stable identifier for a user at their upstream IdP, sitting at rest for the lifetime of a refresh
token. Deployments that seal upstream identity at rest now have to strip or seal it in their storage layer,
across six store methods and three different types. That's a lot of surface for a feature they don't use.
Proposal
Record the value only when disclosure can actually happen. Both places it originates are Handler methods
with h.config in reach:
carryFirstUpstreamIdentity(callback.go:487, called at:294)completeDeviceLogin(device_verification.go:286)
When len(h.config.SubjectIdentifierAudiences) == 0, leave VerifiedUpstream zero. Everything downstream
already treats a zero value as "no claim", so nothing else changes.
Tradeoff
If an operator turns disclosure on later, sessions created while it was off have no value, so their tokens
(including refreshes) won't carry sub_id until the user logs in again. I think that's the right default:
disclosure applies from the next login. It's worth a line in the SubjectIdentifierAudiences doc comment.
Tests
- With
SubjectIdentifierAudiencesempty, the stored authorize code session, device confirmation and device
request have a zeroVerifiedUpstream. Cover both the authorization-code and the device flow. - With it set, the existing
sub_idtests keep passing unchanged.
Context
Until this lands, deployments that keep upstream identity out of storage have to strip the field in a
storage decorator. With this change that workaround can go.
Activity
Skip upstream identity capture when sub_id is off (#6956)