Documentation ¶
Index ¶
Constants ¶
View Source
const ( RoleAdmin = "ADMIN" RoleUser = "USER" )
These are the expected values for Claims.Roles.
View Source
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 New ¶
New creates an *Auth for use. It will error if: - The private key is nil. - The public key func is nil. - The key ID is blank. - The specified algorithm is unsupported.
func (*Auth) GenerateToken ¶
GenerateToken generates a signed JWT token string representing the user Claims.
type Claims ¶
type Claims struct { Roles []string `json:"roles"` jwt.StandardClaims }
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.
Click to show internal directories.
Click to hide internal directories.