Nais Security Token Service (STS) is an OAuth 2.1 authorization server for Kubernetes workloads running on Nais.
STS issues short-lived access tokens to clients for exactly one target audience. Clients must authenticate with workload identity assertions and have access through an authorization policy.
The service supports:
- RFC 6749 Client Credentials for machine-to-machine access
- RFC 8693 Token Exchange for on-behalf-of flows when subject-token issuers are configured
Kubernetes API server (workload issuer)
/ \
issues identity token issues identity token
▼ ▼
Registrator Client
│ │
registers clients and policies requests or exchanges token
│ with identity token
└──────────► STS ◄───────────┘
│
issues token
▼
Client ── presents token ──► Target
- The Kubernetes API server acts as the workload issuer. It issues projected service account tokens that workloads use to authenticate with STS.
- A registrator registers clients and their authorization policies with STS. It can register clients only for its configured workload issuer.
- A client is a registered Kubernetes workload that requests tokens. It acts as an OAuth client.
- An authorization policy states which target a client can request and which roles its token receives.
- STS authenticates the client, checks its policy, and issues a token for one target. Token exchange also requires a subject token from an accepted issuer.
- A target is the intended audience of the token. The receiving service validates the token before accepting it.
- Architecture: components, project layout, request flows, and storage
- Configuration: YAML settings and deployment values
- Branch deployments: automatic dev-nais deployments from protected branches
- Client registration: register clients and policies
- Client usage: request tokens with client credentials or token exchange
- Benchmarks: run and interpret local benchmarks
Install mise and start Docker. Run the commands in this section from the repository root.
mise run dev # prepares k3d and PostgreSQL, then runs both servicesFor IntelliJ, run mise run dev:setup first, then run "STS Local".
After mise run sts-operator:k3d:sample, try the token flows with Kubernetes service account tokens:
mise run sts-authserver:dev:token:m2m: get a client credentials token.mise run sts-authserver:dev:token:obo: exchange a subject token from the mock issuer.
See the operator README for details.
mise run sts-authserver:mockThis starts PostgreSQL and a mock OAuth server, seeds fixtures and runs the authserver with sts-authserver/config.yaml, copied from config.example.yaml if absent.
It uses the same ports as the k3d workflow, so run only one at a time.
Endpoints:
- http://localhost:8080/.well-known/oauth-authorization-server
- http://localhost:8081/healthz
- http://localhost:8081/readyz
- http://localhost:8081/metrics
Try the token flows:
mise run sts-authserver:mock:token:m2m: get a client credentials token.mise run sts-authserver:mock:token:obo: exchange a subject token.
Run mise tasks --all for all commands.