Skip to content

jwtauthccl: support JSON Pointer for identity claim lookup#165085

Open
alex-berger wants to merge 1 commit intocockroachdb:masterfrom
alex-berger:master
Open

jwtauthccl: support JSON Pointer for identity claim lookup#165085
alex-berger wants to merge 1 commit intocockroachdb:masterfrom
alex-berger:master

Conversation

@alex-berger
Copy link
Contributor

@alex-berger alex-berger commented Mar 6, 2026

Release note: Allow using values from nested JWT claims as user identity.

This change allows the identity claim setting to accept a JSON Pointer (RFC 6901) in addition to a simple claim name, enabling CockroachDB to extract identity from deeply nested token structures.

Motivation

Kubernetes ServiceAccount tokens store the serviceaccount UID inside a nested claim at /kubernetes.io/serviceaccount/uid rather than in a top-level field, see below example of a Kubernetes ServiceAccount Token (JWT). With this PR we can for example set server.jwt_authentication.claim to /kubernetes.io/serviceaccount/uid to use a ServiceAccount's unique identifier as user identity. So this is another mini-step towards #103110 - Scalable and flexible JWT based authentication.

{
  "aud": [
    "cockroachdb"
  ],
  "exp": 1772783261,
  "iat": 1772696861,
  "iss": "https://my-issuer/...",
  "jti": "d536bab9-f0fc-46ad-a09d-5d85ac85dce1",
  "kubernetes.io": {
    "namespace": "my-namespace",
    "node": {
      "name": "ip-10-176-16-155.eu-central-1.compute.internal",
      "uid": "6c9b214a-b6d8-43f9-b1e0-0e15b6126eda"
    },
    "pod": {
      "name": "my-workload-54b8897d8-88wzg",
      "uid": "c33ed74a-738c-499a-96d1-0bfdb68fee91"
    },
    "serviceaccount": {
      "name": "my-service-account",
      "uid": "136f6af7-4e5a-4891-b778-992ad1674b02"
    },
    "warnafter": 1772700468
  },
  "nbf": 1772696861,
  "sub": "system:serviceaccount:my-namespace:my-service-account"
}

Kubernetes ServiceAccount tokens store the serviceaccount UID inside a
nested claim at /kubernetes.io/serviceaccount/uid rather than in a
top-level field. This change allows the identity claim setting to accept
a JSON Pointer (RFC 6901) in addition to a simple claim name, enabling
CockroachDB to extract identity from deeply nested token structures.

Signed-off-by: Alexander Berger <alex-berger@gmx.ch>
@alex-berger alex-berger requested review from a team as code owners March 6, 2026 14:06
@trunk-io
Copy link
Contributor

trunk-io bot commented Mar 6, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@blathers-crl
Copy link

blathers-crl bot commented Mar 6, 2026

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

Before a member of our team reviews your PR, I have some potential action items for you:

  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added the O-community Originated from the community label Mar 6, 2026
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community T-product-security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants