auth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingCredentials   = errors.New("missing credentials")
	ErrUntrustedProxy       = errors.New("request did not originate from a trusted proxy")
	ErrMissingTrustedMarker = errors.New("request missing trusted forward auth marker")
	ErrMissingSubject       = errors.New("token missing subject")
)

Functions

func NewContext

func NewContext(ctx context.Context, principal *Principal) context.Context

func RequireActiveBearerSession

func RequireActiveBearerSession(validator SessionValidator) func(http.Handler) http.Handler

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	Username     string   `json:"username"`
	Name         string   `json:"name"`
	Email        string   `json:"email"`
	Groups       []string `json:"groups"`
	Scopes       []string `json:"scopes"`
	SessionID    string   `json:"session_id"`
	TokenVersion int      `json:"token_version"`
	jwt.RegisteredClaims
}

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(cfg config.Config) *Authenticator

func (*Authenticator) AuthenticateRequest

func (a *Authenticator) AuthenticateRequest(r *http.Request) (*Principal, error)

func (*Authenticator) OptionalPrincipalMiddleware

func (a *Authenticator) OptionalPrincipalMiddleware() func(http.Handler) http.Handler

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(cfg config.Config) *Authorizer

func (*Authorizer) IsAdmin

func (a *Authorizer) IsAdmin(principal *Principal) bool

func (*Authorizer) RequireAdmin

func (a *Authorizer) RequireAdmin() func(http.Handler) http.Handler

func (*Authorizer) RequireAuthenticated

func (a *Authorizer) RequireAuthenticated() func(http.Handler) http.Handler

type Principal

type Principal struct {
	Subject      string
	Username     string
	Name         string
	Email        string
	Groups       []string
	Scopes       []string
	SessionID    string
	TokenVersion int
	Source       PrincipalSource
}

func FromContext

func FromContext(ctx context.Context) (*Principal, bool)

type PrincipalSource

type PrincipalSource string
const (
	PrincipalSourceForwardAuth PrincipalSource = "forward_auth"
	PrincipalSourceBearerJWT   PrincipalSource = "bearer_jwt"
)

type SessionValidator

type SessionValidator interface {
	ValidateSession(ctx context.Context, sessionID string) (bool, error)
}

Jump to

Keyboard shortcuts

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