Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package auth authenticates the platform's callers (§13.2). Seats present a projected ServiceAccount token whose only audience is steadmesh-gateway; the controller presents its own ServiceAccount token with the default audience. Both are verified with a Kubernetes TokenReview, and the principal is derived from the verified username, never from request content.

Index

Constants

View Source
const PodUIDExtra = "authentication.kubernetes.io/pod-uid"

PodUIDExtra is the TokenReview extra field carrying the bound Pod UID.

Variables

View Source
var (
	ErrUnauthenticated = errors.New("unauthenticated")
	ErrForbidden       = errors.New("forbidden")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	// Seat resolves a gateway-audience token to an active seat.
	Seat(ctx context.Context, token string) (Seat, error)
	// Controller verifies the controller's token.
	Controller(ctx context.Context, token string) error
	// Console verifies the console's token. It is forbidden when no console
	// identity is configured.
	Console(ctx context.Context, token string) error
}

Authenticator verifies bearer tokens.

type Fake

type Fake struct {
	// contains filtered or unexported fields
}

Fake is an in-memory Authenticator for tests.

func NewFake

func NewFake(controllerToken string) *Fake

NewFake returns a Fake accepting controllerToken on the internal API.

func (*Fake) AddSeat

func (f *Fake) AddSeat(token string, seat Seat)

AddSeat makes token authenticate as seat.

func (*Fake) Console

func (f *Fake) Console(_ context.Context, token string) error

Console implements Authenticator.

func (*Fake) Controller

func (f *Fake) Controller(_ context.Context, token string) error

Controller implements Authenticator.

func (*Fake) Seat

func (f *Fake) Seat(_ context.Context, token string) (Seat, error)

Seat implements Authenticator.

func (*Fake) SetConsole

func (f *Fake) SetConsole(token string)

SetConsole makes token authenticate on the console API.

type Seat

type Seat struct {
	SeatID string
	PodUID string
}

Seat is an authenticated seat principal.

type SeatResolver

type SeatResolver interface {
	SeatByServiceAccount(ctx context.Context, namespace, serviceAccount string) (string, error)
}

SeatResolver maps a verified ServiceAccount to its active seat id.

type TokenReview

type TokenReview struct {
	// contains filtered or unexported fields
}

TokenReview is the production Authenticator.

func NewTokenReview

func NewTokenReview(client kubernetes.Interface, seats SeatResolver, controllerUsername, consoleUsername string) *TokenReview

NewTokenReview returns an Authenticator using client for TokenReviews. controllerUsername is the only identity accepted on the internal API, e.g. system:serviceaccount:steadmesh-system:steadmesh-controller. consoleUsername is the only identity accepted on the console API; empty accepts none.

func (*TokenReview) Console

func (a *TokenReview) Console(ctx context.Context, token string) error

Console implements Authenticator.

func (*TokenReview) Controller

func (a *TokenReview) Controller(ctx context.Context, token string) error

Controller implements Authenticator.

func (*TokenReview) Seat

func (a *TokenReview) Seat(ctx context.Context, token string) (Seat, error)

Seat implements Authenticator. The seat mapping is resolved on every call so a retired seat loses access immediately; only the TokenReview is cached.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL