auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrUnauthorised

func NewErrUnauthorised(reason string) error

Types

type Authenticator

type Authenticator interface {
	// Authenticate takes a token and returns an authenticated Customer
	Authenticate(ctx context.Context, token string) (*Customer, error)

	// CanAccept takes a token and return true if it is supported. This function does not authenticate the token, only
	// whether the Authenticator can handle it.
	CanAccept(token string) bool
}

type Customer

type Customer struct {
	Id        string `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Brand     string `json:"brand"`
}

func (Customer) Validate

func (c Customer) Validate() error

Validate returns an error if the Customer is invalid

type ErrUnauthorised

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

func (ErrUnauthorised) Error

func (e ErrUnauthorised) Error() string

type Provider

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

Provider holds a slice of available authenticators

func NewProvider

func NewProvider(authenticators ...Authenticator) *Provider

NewProvider returns a new Provider containing the provided authenticators

func (Provider) Get

func (p Provider) Get(token string) (Authenticator, error)

Get takes a token and returns the first Authenticator that can accept the token.

Directories

Path Synopsis
jwt

Jump to

Keyboard shortcuts

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