auth

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidScope = errors.New("invalid scope")
	ErrInvalidToken = errors.New("invalid token")
	ErrUnauthorized = errors.New("unauthorized")
)

Functions

func Authorize

func Authorize(principal Principal, requested Scope) error

Types

type Access

type Access string
const (
	AccessControl Access = "control"
	AccessView    Access = "view"
	AccessAdapter Access = "adapter"
	AccessAll     Access = "*"
)

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, token string) (Principal, error)
	Authorize(ctx context.Context, principal Principal, scope Scope) error
}

type Kind

type Kind string
const (
	KindSession Kind = "session"
	KindGroup   Kind = "group"
	KindAPI     Kind = "api"
)

type Principal

type Principal struct {
	Subject string
	Scopes  []Scope
}

type Scope

type Scope struct {
	Kind   Kind
	ID     string
	Access Access
}

func API

func API() Scope

func GroupControl

func GroupControl(groupID string) Scope

func ParseScope

func ParseScope(raw string) (Scope, error)

func SessionAdapter

func SessionAdapter(sessionID string) Scope

func SessionControl

func SessionControl(sessionID string) Scope

func SessionView

func SessionView(sessionID string) Scope

func (Scope) String

func (s Scope) String() string

func (Scope) Validate

func (s Scope) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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