auth

package
v0.0.0-...-aff46f4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: GPL-3.0, GPL-3.0-or-later Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorUnauthenticated = errors.New("talaria/auth: unauthenticated")

ErrorUnauthenticated signifies a failed login attempt

Functions

func FromContext

func FromContext(ctx context.Context) (token string, ok bool)

FromContext extracts authentication tokens from a context

func OnlyAdmin

func OnlyAdmin(next users.Service, key *ecdsa.PublicKey) users.Service

OnlyAdmin is a user service middleware that restricts user manipulation to admin users

func WithAuth

func WithAuth(ctx context.Context, token string) context.Context

WithAuth adds a JWT token to a context

Types

type Authenticator

type Authenticator interface {
	Login(ctx context.Context, username, password string) (token string, err error)
}

Authenticator handles login requests and returns JSON web tokens in exchange for credentials.

Tokens are signed via elliptical curve crypto (for shorter tokens). This also means that public keys can be distributed to all middlewares and other services so that they can independently validate tokens

func NewAuthenticator

func NewAuthenticator(us users.Service, key *ecdsa.PrivateKey) (Authenticator, error)

Jump to

Keyboard shortcuts

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