Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckClaimForPermission ¶
CheckClaimForPermission is just a shortcut to be able to recurse over the other function.
func CheckPermission ¶
CheckPermission will checks a token if it contains a given permission.
Types ¶
type Claims ¶
type Claims struct { jwt.StandardClaims UserID string `json:"user-id"` Permissions *Permissions `json:"permissions"` }
Claims are the information that is stored inside a token. If the token was verified correctly, these claims represent the truth.
Permissions is a nested map, with arbitrary depths, with strings for keys and a bool as value. This could be explained by the Backus–Naur form: `Permissions = map[string]Permissions | bool` The ending bool represent weather you
func GetClaimsFromVerifiedJwt ¶
GetClaimsFromVerifiedJwt will return the claims if the token is valid. If the token is invalid, nil is returned along with an error.
type Permissions ¶
type Permissions struct { Next map[string]*Permissions `json:"n,omitempty"` Permit bool `json:"p,omitempty"` }
Permissions should contain either a Permit or the Next permissions. The Permit property should only considered if the map is nil.
type UnauthorizedError ¶
type UnauthorizedError struct {
}UnauthorizedError is used when the token is invalid, or there was some other error while parsing the claim.
func (UnauthorizedError) Error ¶
func (ue UnauthorizedError) Error() string