Documentation ¶
Overview ¶
Package auth provides authentication and authorization support. Authentication: You are who you say you are. Authorization: You have permission to do what you are requesting to do.
Index ¶
Constants ¶
const ( RuleAuthenticate = "auth" RuleAny = "rule_any" RuleAdminOnly = "rule_admin_only" RuleUserOnly = "rule_user_only" RuleAdminOrSubject = "rule_admin_or_subject" )
These are the current set of rules we have for auth.
Variables ¶
var ErrForbidden = errors.New("attempted action is not allowed")
ErrForbidden is returned when a auth issue is identified.
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) Authenticate ¶
Authenticate processes the token to validate the sender's token is valid.
func (*Auth) Authorize ¶
Authorize attempts to authorize the user with the provided input roles, if none of the input roles are within the user's claims, we return an error otherwise the user is authorized.
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.