auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 13 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

This section is empty.

Functions

func WithPrincipal

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

Types

type Authenticator

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

func New

func New(configuration Configuration) (*Authenticator, error)

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(request *http.Request) (Principal, error)

func (*Authenticator) Middleware

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

type Configuration

type Configuration struct {
	AllowLoopback      bool
	TrustedProxies     []netip.Prefix
	HumanNameHeader    string
	HumanEmailHeader   string
	HumanAccountHeader string
	HumanRepositories  map[string]bool
	HumanCanWrite      bool
	CredentialStore    Credentials
}

type Credentials

type Credentials struct {
	Version int     `yaml:"version"`
	Tokens  []Token `yaml:"tokens"`
}

func LoadCredentials

func LoadCredentials(path string) (Credentials, error)

type Permission

type Permission string
const (
	Read  Permission = "read"
	Write Permission = "write"
)

type Principal

type Principal struct {
	Name         string
	Email        string
	Account      string
	Kind         store.AuthorKind
	Verification string
	Repositories map[string]bool
	Permissions  map[Permission]bool
}

func FromContext

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

func (Principal) Author

func (p Principal) Author() store.Author

func (Principal) Can

func (p Principal) Can(repository string, permission Permission) bool

type Token

type Token struct {
	Name         string       `yaml:"name"`
	SHA256       string       `yaml:"sha256"`
	Repositories []string     `yaml:"repositories"`
	Permissions  []Permission `yaml:"permissions"`
}

Jump to

Keyboard shortcuts

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