Documentation ¶
Index ¶
- Constants
- Variables
- func AddAuthenticateHeader(w http.ResponseWriter, err error, scopes ...string)
- func AuhtorizationHandler(scope string, h httprouter.Handle) httprouter.Handle
- func ExtractToken(r *http.Request) (string, error)
- func SignToken(c *Claims, d *time.Duration) (string, error)
- type Claims
Constants ¶
View Source
const ( // ScopeAllRead represents the global read permission scope ScopeAllRead = "read:all" // ScopeAllWrite represents the global write permission scope ScopeAllWrite = "write:all" // ScopeItemRead represents the item read permission scope ScopeItemRead = "read:item" // ScopeItemWrite represents the item write permission scope ScopeItemWrite = "write:item" // ScopeHideoutRead represents the hideout read permission scope ScopeHideoutRead = "read:hideout" // ScopeHideoutWrite represents the hideout write permission scope ScopeHideoutWrite = "write:hideout" // ScopeLocationRead represents the location read permission scope ScopeLocationRead = "read:location" // ScopeLocationWrite represents the location write permission scope ScopeLocationWrite = "write:location" // ScopeStatisticRead represents the statistic read permission scope ScopeStatisticRead = "read:statistic" // ScopeStatisticWrite represents the statistic write permission scope ScopeStatisticWrite = "write:statistic" // ScopeUserRead represents the user read permission scope ScopeUserRead = "read:user" // ScopeUserWrite represents the user write permission scope ScopeUserWrite = "write:user" // ScopeTokenWrite represents the token write permission scope ScopeTokenWrite = "write:token" )
Variables ¶
View Source
var ( // ErrInvalidScope indicates that a scope value is not valid ErrInvalidScope = errors.New("no or invalid scopes") // ErrInvalidSubject indicates that the subject value is not valid ErrInvalidSubject = errors.New("invalid subject") // ErrInvalidAudience indicates that the audience value does not match ErrInvalidAudience = errors.New("audience mismatch") // ErrExpiredToken indicates that the token is expired ErrExpiredToken = errors.New("token is expired") // ErrNotBefore indicates that the token is not yet valid ErrNotBefore = errors.New("token is not yet valid") // ErrMalformed indicates that the token is malformed ErrMalformed = errors.New("token is malformed") // ErrInvalidToken indicates that the token is invalid ErrInvalidToken = errors.New("token is invalid") )
View Source
var ( // ErrNoAuthHeader indicates that the authorization is not set ErrNoAuthHeader = errors.New("authorization header not set") // ErrInvalidAuthHeader indicates that the authorization is invalid ErrInvalidAuthHeader = errors.New("invalid authorization header") )
Functions ¶
func AddAuthenticateHeader ¶
func AddAuthenticateHeader(w http.ResponseWriter, err error, scopes ...string)
AddAuthenticateHeader adds the "WWW-Authenticate" header to the response
func AuhtorizationHandler ¶
func AuhtorizationHandler(scope string, h httprouter.Handle) httprouter.Handle
AuhtorizationHandler returns a JWT authorization handler
func ExtractToken ¶
ExtractToken extracts a token from a request header
Types ¶
Click to show internal directories.
Click to hide internal directories.