auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: AGPL-3.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthorized = errors.New("not authorized")

Functions

This section is empty.

Types

type AlwaysAllowAuthenticator

type AlwaysAllowAuthenticator struct {
}

AlwaysAllowAuthenticator accepts any access token.

func AlwaysAllow

func AlwaysAllow() *AlwaysAllowAuthenticator

func (*AlwaysAllowAuthenticator) Authenticate

func (a *AlwaysAllowAuthenticator) Authenticate(ctx context.Context, token string) error

type Authenticator

type Authenticator interface {
	// Authenticate validates the given access token.
	// The implementation should return an error if the token is not valid for any reason.
	Authenticate(ctx context.Context, token string) error
}

type StaticAuthenticator

type StaticAuthenticator struct {
	AllowedTokens []string
}

StaticAuthenticator accepts a list of predetermined access tokens.

func Static

func Static(tokens ...string) *StaticAuthenticator

func (*StaticAuthenticator) Authenticate

func (a *StaticAuthenticator) Authenticate(ctx context.Context, token string) error

Jump to

Keyboard shortcuts

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