Documentation ¶
Overview ¶
Package auth provides authentication and authorization support.
Index ¶
Constants ¶
const ( RoleAdmin = "ADMIN" RoleUser = "USER" )
These constants represet the set of roles.
const Key ctxKey = 1
Key is used to store/retrieve a Claims value from a context.Context.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth is used to authenticate clients. It can generate a token for a set of user claims and recreate the claims by parsing the token.
func (*Auth) GenerateToken ¶
GenerateToken generates a signed JWT token string representing the user Claims.
type Claims ¶
type Claims struct { jwt.StandardClaims Auth StandardClaims }
Claims represents the authorization claims transmitted via a JWT.
func (Claims) Authorized ¶
Authorized returns true if the claim matches the provided role.
type KeyLookup ¶
type KeyLookup interface { PrivateKey(kid string) (*rsa.PrivateKey, error) PublicKey(kid string) (*rsa.PublicKey, error) }
KeyLookup declares a method set of behavior for looking up private and public keys for JWT use.
type StandardClaims ¶
type StandardClaims struct {
Role string `json:"ROLE"`
}
StandardClaims represents claims for the applications.