auth

package
v0.0.0-...-c739cb8 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractToken

func ExtractToken(r *http.Request) (string, bool)

ExtractToken checks both the 'Authorization' HTTP header and the 'token' URL query parameter for an authentication token

Types

type Authenticator

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

Authenticator is the module in charge of authentication

func NewAuthenticator

func NewAuthenticator(db DB, key *rsa.PrivateKey, aud, iss string) *Authenticator

NewAuthenticator is the Authenticator constructor

func (*Authenticator) Basic

func (a *Authenticator) Basic(uname, password string) error

Basic tests whether a pair of basic credentials are valid

func (*Authenticator) GenerateJWT

func (a *Authenticator) GenerateJWT(uname string) (string, error)

GenerateJWT generates and signs a token for a given user

func (*Authenticator) SignJWT

func (a *Authenticator) SignJWT(tk *jwt.Token) (string, error)

SignJWT signs a token with the authenticator's key

func (*Authenticator) ValidateJWT

func (a *Authenticator) ValidateJWT(tkString string) (*CustomClaims, error)

ValidateJWT returns the claims within a token as a CustomClaims obect and validates its fields

func (*Authenticator) Wrap

Wrap wraps an HTTP handler function, and checks both the

Populates the access token claims object in the req ctx. Accessible through the GetClaims() function

type CustomClaims

type CustomClaims struct {
	jwt.StandardClaims
}

CustomClaims represents claims we wish to make and verify with JWTs

func GetClaims

func GetClaims(r *http.Request) *CustomClaims

GetClaims returns the claims in a context object

func NewCustomClaims

func NewCustomClaims(sub, aud, iss string, lifetime time.Duration) *CustomClaims

NewCustomClaims returns a new CustomClaims object

type DB

type DB interface {
}

DB represents the storage needs of the authenticator module

Jump to

Keyboard shortcuts

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