auth

package
v0.0.0-...-3301e3d Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PadlAPIAudience user audience for Padl API
	PadlAPIAudience = "api"
	// ServiceAccountAudience is the service account
	// audience for Padl API
	ServiceAccountAudience = "decrypt"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

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

Authenticator is the module in charge of authentication

func NewAuthenticator

func NewAuthenticator(db store.Database, key *rsa.PrivateKey, iss, aud 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(email string, aud 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, allowedAuds ...string) (*CustomClaims, error)

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

type CustomClaims

type CustomClaims struct {
	jwt.StandardClaims
}

CustomClaims represents claims we wish to make and verify with JWTs

func NewCustomClaims

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

NewCustomClaims returns a new CustomClaims object

Jump to

Keyboard shortcuts

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