auth

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth bridges OIDC (dex) bearers to a typed Identity passed through req.Context. V0.1 implements the Verifier interface as a JWKS-fetching JWT validator ; dev mode bypasses the layer entirely via Server.Auth=nil.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = errors.New("auth: invalid token")

ErrInvalidToken is the standard error for a malformed / expired / unverifiable token. Handlers translate this to 401.

Functions

func WithIdentity

func WithIdentity(ctx context.Context, ident Identity) context.Context

WithIdentity attaches ident to ctx so downstream handlers can pull it back with IdentityFrom.

Types

type Identity

type Identity struct {
	Subject string
	Groups  []string
}

Identity is the request-scoped principal we extract from a verified OIDC token. Subject is the dex subject claim (sub). Groups carry the operator's group memberships ; we map those to project ACL.

func IdentityFrom

func IdentityFrom(ctx context.Context) (Identity, bool)

IdentityFrom retrieves the identity attached by WithIdentity. When no identity is present, returns the zero Identity + false.

func (Identity) HasGroup

func (i Identity) HasGroup(g string) bool

HasGroup reports whether the identity is in g. Convenience for ACL checks.

type StaticVerifier

type StaticVerifier struct {
	Token    string
	Identity Identity
}

StaticVerifier is a test/dev verifier that accepts a fixed token and returns a fixed identity. Useful for local development without dex configured.

func (StaticVerifier) Verify

func (s StaticVerifier) Verify(_ context.Context, bearer string) (Identity, error)

type Verifier

type Verifier interface {
	Verify(ctx context.Context, bearer string) (Identity, error)
}

Verifier validates a bearer token and returns the corresponding Identity. V0.1 has one impl (OIDC via dex) ; tests can drop in a fake by implementing the interface directly.

Jump to

Keyboard shortcuts

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