Documentation ¶
Overview ¶
Package auth provides authentication and authorization support.
Index ¶
Constants ¶
const ( RoleAdmin = "ADMIN" RoleUser = "USER" )
These are the expected values for Claims.Roles.
Variables ¶
This section is empty.
Functions ¶
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 ¶
[PS] Helper functions GenerateToken generates a signed JWT token string representing the user Claims.
type Claims ¶
type Claims struct { jwt.RegisteredClaims // BUG ? //jwt.StandardClaims Roles []string `json:"roles"` }
Claims represents the authorization claims transmitted via a JWT.
func (Claims) Authorized ¶
Authorized returns true if the claims has at least one of the provided roles.
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. [PS] interface is used for fetching the key because we want to abstract it from the key store. Any keystore can be used [PS] the methods will be implemented by the caller of this interface