authenticator

package
v0.0.0-...-62de7c0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidSecret is returned when an empty secret is given
	ErrInvalidSecret = errors.New("Please provide a valid secret")

	// ErrInvalidToken is returned when trying to parse an invalid token
	ErrInvalidToken = errors.New("Token is invalid")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	GenerateToken(*types.User) (string, error)
	CheckToken(string) error
}

Authenticator describes how an authenticator should operate

func NewJWTAuthenticator

func NewJWTAuthenticator(secret []byte) (Authenticator, error)

NewJWTAuthenticator returns a new instance of a JWTAuthenticator

type JWTAuthenticator

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

JWTAuthenticator handles generating and parsing JWTs

func (JWTAuthenticator) CheckToken

func (a JWTAuthenticator) CheckToken(tokenString string) error

CheckToken attempts to parse an auth token

func (JWTAuthenticator) GenerateToken

func (a JWTAuthenticator) GenerateToken(u *types.User) (string, error)

GenerateToken takes a user and generates a JWT containing their user ID

Jump to

Keyboard shortcuts

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