auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotApplicable   = errors.New("auth: not applicable to this request")
	ErrUnauthenticated = errors.New("auth: unauthenticated")
	ErrForbidden       = errors.New("auth: forbidden")
)

Functions

func WithPrincipal

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

Types

type Action

type Action struct {
	Service string
	Method  string
	Verb    string
}

type AllowAll

type AllowAll struct{}

func (AllowAll) Authorize

func (AllowAll) Authorize(_ context.Context, _ Principal, _ Action, _ Target) error

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, req Request) (Principal, error)
}

func Chain

func Chain(as ...Authenticator) Authenticator

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, p Principal, a Action, t Target) error
}

type LocalPeerCred

type LocalPeerCred struct{}

func (LocalPeerCred) Authenticate

func (LocalPeerCred) Authenticate(_ context.Context, req Request) (Principal, error)

type PeerCred

type PeerCred struct {
	Pid int32
	Uid uint32
	Gid uint32
}

PeerCred holds Unix peer credentials obtained via SO_PEERCRED. Using a package-defined type avoids a direct dependency on syscall.Ucred, which is Linux-specific.

type Principal

type Principal struct {
	ID          string
	DisplayName string
	Kind        string
	Metadata    map[string]string
}

func PrincipalFromContext

func PrincipalFromContext(ctx context.Context) (Principal, bool)

type RejectAll

type RejectAll struct{}

func (RejectAll) Authenticate

func (RejectAll) Authenticate(_ context.Context, _ Request) (Principal, error)

type Request

type Request struct {
	Scheme     string
	Headers    http.Header
	PeerCred   *PeerCred
	RemoteAddr string
	Method     string
	HTTP       *http.Request
}

type Target

type Target struct {
	Kind  string
	ID    string
	Area  string
	Class string
	Attr  map[string]string
}

Directories

Path Synopsis
Package audit emits AuthEvent payloads to the event store.
Package audit emits AuthEvent payloads to the event store.
Package migrations embeds auth SQL migrations for goose.
Package migrations embeds auth SQL migrations for goose.
Package sessions stores cookie-based browser sessions with HMAC-signed access cookies and rotating refresh cookies.
Package sessions stores cookie-based browser sessions with HMAC-signed access cookies and rotating refresh cookies.
Package throttle implements a soft per-IP × per-method failed-auth throttle.
Package throttle implements a soft per-IP × per-method failed-auth throttle.

Jump to

Keyboard shortcuts

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