access

package
v6.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoCredentials indicates no recognizable credentials were supplied.
	ErrNoCredentials = errors.New("access: no credentials provided")
	// ErrInvalidCredential signals that supplied credentials were rejected by a provider.
	ErrInvalidCredential = errors.New("access: invalid credential")
	// ErrNotHandled tells the manager to continue trying other providers.
	ErrNotHandled = errors.New("access: not handled")
)

Functions

func RegisterProvider

func RegisterProvider(typ string, factory ProviderFactory)

RegisterProvider registers a provider factory for a given type identifier.

Types

type Manager

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

Manager coordinates authentication providers.

func NewManager

func NewManager() *Manager

NewManager constructs an empty manager.

func (*Manager) Authenticate

func (m *Manager) Authenticate(ctx context.Context, r *http.Request) (*Result, error)

Authenticate evaluates providers until one succeeds.

func (*Manager) Providers

func (m *Manager) Providers() []Provider

Providers returns a snapshot of the active providers.

func (*Manager) SetProviders

func (m *Manager) SetProviders(providers []Provider)

SetProviders replaces the active provider list.

type Provider

type Provider interface {
	Identifier() string
	Authenticate(ctx context.Context, r *http.Request) (*Result, error)
}

Provider validates credentials for incoming requests.

func BuildProviders

func BuildProviders(root *config.Config) ([]Provider, error)

BuildProviders constructs providers declared in configuration.

func ReconcileProviders added in v6.0.8

func ReconcileProviders(oldCfg, newCfg *config.Config, existing []Provider) (result []Provider, added, updated, removed []string, err error)

ReconcileProviders builds the desired provider list by reusing existing providers when possible and creating or removing providers only when their configuration changed. It returns the final ordered provider slice along with the identifiers of providers that were added, updated, or removed compared to the previous configuration.

type ProviderFactory

type ProviderFactory func(cfg *config.AccessProvider, root *config.Config) (Provider, error)

ProviderFactory builds a provider from configuration data.

type Result

type Result struct {
	Provider  string
	Principal string
	Metadata  map[string]string
}

Result conveys authentication outcome.

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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