Skip to content
naisPublic

About

nais security token service

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

nais-sts

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:

How it works

              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
  1. The Kubernetes API server acts as the workload issuer. It issues projected service account tokens that workloads use to authenticate with STS.
  2. A registrator registers clients and their authorization policies with STS. It can register clients only for its configured workload issuer.
  3. A client is a registered Kubernetes workload that requests tokens. It acts as an OAuth client.
  4. An authorization policy states which target a client can request and which roles its token receives.
  5. 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.
  6. A target is the intended audience of the token. The receiving service validates the token before accepting it.

Documentation

Local development

Install mise and start Docker. Run the commands in this section from the repository root.

Authserver and operator against k3d

mise run dev  # prepares k3d and PostgreSQL, then runs both services

For 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.

Standalone authserver with mock issuers

mise run sts-authserver:mock

This 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:

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.

About

nais security token service

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages