Documentation ¶
Overview ¶
Package auth provides authentication and authorization support.
Index ¶
Constants ¶
View Source
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 ¶
GenerateToken generates a signed JWT token string representing the user Claims.
type Claims ¶
type Claims struct { jwt.RegisteredClaims 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.
Click to show internal directories.
Click to hide internal directories.