feat(userauth): surface gitlab.identities on the verified token

What

  • Adds Identities []IdentityClaim to GitLabClaims. Each entry has Kind and LocalID.
  • An absent gitlab.identities claim and an empty list both parse to an empty slice.
  • A claim whose value cannot be read fails verification with reason invalid_token. That covers a non-list (including null), an entry that is not an object, and a missing or malformed kind or local_id.
  • A sent claim never reads as absent. A consumer checks len(Identities) > 0.
  • kind must be a string. A numeric kind is rejected, not stringified.
  • The library validates neither the set of kinds nor the number of entries.
  • gitlab.job is unchanged. It still never rejects a token, because it is never an authorization input.
  • docs/relationships-api.md describes the claim in its token-shape bullet.

An earlier revision added a HasIdentities flag. Rejecting an unreadable claim removes the case that flag reported, so the flag is gone.

Why

Rails writes gitlab.identities only for a composite identity. That is a service account acting for a human user. In that token, the top-level fields describe only the service account. The human appears only in identities. GitLab authorizes such a request only when both parties have access.

A consumer that reads only the top-level fields never checks the human. It could let a human with less access act with the agent's permissions. Before this change the library dropped the claim, so a consumer could not tell it was there.

An unreadable claim fails verification. It does not parse to nothing. An empty reading is the one that authorizes the service account alone.

Trigger (spec S02) has no two-party authorization. It refuses any token that carries the claim, with reason composite_identity. This is Step 0 of https://gitlab.com/gitlab-org/primitives/trigger/-/merge_requests/120.

AC 9 needs rewording to cover a claim that names an identity, not any claim at all. A claim naming at least one identity still gets composite_identity. An unreadable claim, such as a non-list (including null) or a bad entry, gets invalid_token from the library before Trigger sees it, and an empty list is accepted.

Consumers

Artifact Registry and Trigger pin pseudo-versions of this module. Nothing changes for them until they bump.

No Go consumer can receive a composite token today. Rails mints them only for the gitlab-rails audience, which the library's allowedAudiences does not list.

Edited by Cameron Swords

Merge request reports

Loading
Loading