auth

package
v2.10.1 Latest Latest
Warning

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

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

Documentation

Overview

Package auth is the identity port: who is making this request, and may they do what they are asking. The engine never sees a credential; it sees a Principal, which the HTTP layer puts on the context after an Authenticator has produced one. Authorization is a second port, so a deployment can plug in a policy without touching authentication.

The shape follows Kubernetes: an authenticator chain turns a request into a subject with groups (here Roles), and an authorizer decides on (subject, verb, resource). Cartograph ships the no-identity adapters an unauthenticated single-operator deployment needs; a deployment that puts Cartograph behind an authenticating proxy, or wires an OIDC provider, adds an Authenticator and keeps everything else.

Index

Constants

View Source
const (
	VerbRead           = identity.VerbRead
	VerbWrite          = identity.VerbWrite
	ResourceAccess     = identity.ResourceAccess
	ResourceVault      = identity.ResourceVault
	ResourceSession    = identity.ResourceSession
	ResourceAgent      = identity.ResourceAgent
	RoleReader         = identity.RoleReader
	RoleContributor    = identity.RoleContributor
	RoleStrategyEditor = identity.RoleStrategyEditor
	RoleAdministrator  = identity.RoleAdministrator
	ScopeNone          = identity.ScopeNone
	ScopeTeams         = identity.ScopeTeams
	ScopeAll           = identity.ScopeAll
)

Verbs, resources, roles and scopes, as identity names them.

Variables

View Source
var Anonymous = identity.Anonymous

Anonymous is the principal of a request nobody identified.

View Source
var ErrAgentProposes = identity.ErrAgentProposes

ErrAgentProposes refuses an agent what its person must confirm.

View Source
var ErrForbidden = identity.ErrForbidden

ErrForbidden is returned by an Authorizer that refuses an action.

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

ErrUnauthenticated is returned by an Authenticator that requires a credential and found none, or a bad one.

View Source
var Roles = identity.Roles

Roles is every role, from the least to the most a role may do.

Functions

func Authorize

func Authorize(z Authorizer, next http.Handler) http.Handler

Authorize is the one enforcement point: every request through the API is classified and put to the Authorizer, after the Authenticator has put a principal on the context. A refusal is 403 with the contract's problem shape; the handler never runs.

func Middleware

func Middleware(a Authenticator, next http.Handler) http.Handler

Middleware runs a on every request and puts the principal on the context. A request the authenticator refuses gets 401 and never reaches the handler.

func WithPrincipal

func WithPrincipal(ctx context.Context, p Principal) context.Context

WithPrincipal returns a context carrying p.

Types

type Action

type Action = identity.Action

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

func ActionFor

func ActionFor(r *http.Request) Action

ActionFor classifies a request: its verb from the method, and the manifest it concerns from the path when the path names one (/manifests/{kind}/{id}...). Everything else (the goal tree, the snapshots list, the state manifest) is an action with no kind; the access list, the vault and the session are named as resources.

type AllowAll

type AllowAll struct{}

AllowAll permits every action. The default authorizer.

func (AllowAll) Authorize

Authorize returns nil.

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (Principal, error)
}

Authenticator turns a request into a Principal. Return Anonymous for a request that carries no identity when that is allowed; return ErrUnauthenticated to refuse it.

type Authorizer

type Authorizer = identity.Authorizer

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

type Change added in v2.2.0

type Change = identity.Change

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

type Grants added in v2.2.0

type Grants = identity.Grants

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

type NoAuthentication

type NoAuthentication struct{}

NoAuthentication identifies nobody: every request is Anonymous. The default for a single-operator deployment on a trusted network.

func (NoAuthentication) Authenticate

func (NoAuthentication) Authenticate(*http.Request) (Principal, error)

Authenticate returns Anonymous.

type Principal

type Principal = identity.Principal

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

func PrincipalFrom

func PrincipalFrom(ctx context.Context) Principal

PrincipalFrom returns the principal on ctx, or Anonymous.

type Scope added in v2.2.0

type Scope = identity.Scope

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

type Scoper added in v2.2.0

type Scoper = identity.Scoper

The identity types live in internal/identity, which the engine may import; auth re-exports them so the HTTP side keeps one vocabulary.

Directories

Path Synopsis
Package access is the Authorizer for an access list (docs/adr/0011, TAXONOMY.md D27): four roles, each a bundle of permissions, and teams that scope a contributor's work.
Package access is the Authorizer for an access list (docs/adr/0011, TAXONOMY.md D27): four roles, each a bundle of permissions, and teams that scope a contributor's work.
Package proxy is the Authenticator for a deployment behind an authenticating reverse proxy (oauth2-proxy, Pomerium, Authelia, an ingress with OIDC): the proxy verifies the person and forwards their identity in a header, and this adapter trusts that header.
Package proxy is the Authenticator for a deployment behind an authenticating reverse proxy (oauth2-proxy, Pomerium, Authelia, an ingress with OIDC): the proxy verifies the person and forwards their identity in a header, and this adapter trusts that header.
Package roles is a role-based Authorizer: principals in a write role may read and write, principals in a read role may read, everyone else is refused.
Package roles is a role-based Authorizer: principals in a write role may read and write, principals in a read role may read, everyone else is refused.

Jump to

Keyboard shortcuts

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