auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeNone   = "none"
	ModeBearer = "bearer"
)
View Source
const CookieName = "moltnet_auth"

Variables

This section is empty.

Functions

func WithClaims

func WithClaims(ctx context.Context, claims Claims) context.Context

Types

type Claims

type Claims struct {
	TokenID string
	// contains filtered or unexported fields
}

func ClaimsFromContext

func ClaimsFromContext(ctx context.Context) (Claims, bool)

func (Claims) Allows

func (c Claims) Allows(scope Scope) bool

func (Claims) AllowsAgent

func (c Claims) AllowsAgent(agentID string) bool

type Config

type Config struct {
	Mode                string
	ListenAddr          string
	AllowedOrigins      []string
	TrustForwardedProto bool
	Tokens              []TokenConfig
}

type Error

type Error struct {
	Status  int
	Message string
}

func (*Error) Error

func (e *Error) Error() string

type Policy

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

func NewPolicy

func NewPolicy(config Config) (*Policy, error)

func (*Policy) AuthenticateRequest

func (p *Policy) AuthenticateRequest(request *http.Request, scope Scope) (Claims, error)

func (*Policy) CheckOrigin

func (p *Policy) CheckOrigin(request *http.Request) bool

func (*Policy) Enabled

func (p *Policy) Enabled() bool

func (*Policy) IsSecureRequest

func (p *Policy) IsSecureRequest(request *http.Request) bool

type Scope

type Scope string
const (
	ScopeObserve Scope = "observe"
	ScopeWrite   Scope = "write"
	ScopeAdmin   Scope = "admin"
	ScopeAttach  Scope = "attach"
	ScopePair    Scope = "pair"
)

type TokenConfig

type TokenConfig struct {
	ID     string
	Value  string
	Scopes []Scope
	Agents []string
}

Jump to

Keyboard shortcuts

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