Documentation ¶
Index ¶
- func ExtractToken(r *http.Request) (string, bool)
- type Authenticator
- func (a *Authenticator) Basic(uname, password string) error
- func (a *Authenticator) GenerateJWT(uname string) (string, error)
- func (a *Authenticator) SignJWT(tk *jwt.Token) (string, error)
- func (a *Authenticator) ValidateJWT(tkString string) (*CustomClaims, error)
- func (a *Authenticator) Wrap(h http.HandlerFunc) http.Handler
- type CustomClaims
- type DB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
func (a *Authenticator) Wrap(h http.HandlerFunc) http.Handler
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