Documentation
¶
Index ¶
- Variables
- func NewProvider(invalidRoleHandler http.HandlerFunc, ...) httpauth.AuthorizationProvider
- type JWTAuthenticationProvider
- func (j *JWTAuthenticationProvider) GetIdentity(r *http.Request) (httpauth.Identity, error)
- func (j *JWTAuthenticationProvider) HandleInvalidRole(w http.ResponseWriter, r *http.Request)
- func (j *JWTAuthenticationProvider) HandleLogin(w http.ResponseWriter, r *http.Request, redirect string)
- func (j *JWTAuthenticationProvider) RemoveIdentity(w http.ResponseWriter) error
- func (j *JWTAuthenticationProvider) SetIdentity(w http.ResponseWriter, identity httpauth.Identity) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// AuthorizationCookie is the name of the cookie that jwtprovider uses.
AuthorizationCookie = "authorization"
)
Functions ¶
func NewProvider ¶
func NewProvider(invalidRoleHandler http.HandlerFunc, loginHandler func(w http.ResponseWriter, r *http.Request, redirect string), secret string) httpauth.AuthorizationProvider
NewProvider returns a new authentication provider that runs on jwt.
Types ¶
type JWTAuthenticationProvider ¶
type JWTAuthenticationProvider struct { InvalidRoleHandler http.HandlerFunc LoginHandler func(w http.ResponseWriter, r *http.Request, redirect string) // contains filtered or unexported fields }
JWTAuthenticationProvider is the default authentication provider
func (*JWTAuthenticationProvider) GetIdentity ¶
GetIdentity returns true if the user is any of the specified roles.
func (*JWTAuthenticationProvider) HandleInvalidRole ¶
func (j *JWTAuthenticationProvider) HandleInvalidRole(w http.ResponseWriter, r *http.Request)
HandleInvalidRole calls the http.HandlerFunc called when a user lacks permission for a certain action.
func (*JWTAuthenticationProvider) HandleLogin ¶
func (j *JWTAuthenticationProvider) HandleLogin(w http.ResponseWriter, r *http.Request, redirect string)
HandleLogin calls the http.HandlerFunc called when a user needs to be redirected to the login page.
func (*JWTAuthenticationProvider) RemoveIdentity ¶
func (j *JWTAuthenticationProvider) RemoveIdentity(w http.ResponseWriter) error
RemoveIdentity removes all roles from the user.
func (*JWTAuthenticationProvider) SetIdentity ¶
func (j *JWTAuthenticationProvider) SetIdentity(w http.ResponseWriter, identity httpauth.Identity) error
SetIdentity sets the role of the current user.
Click to show internal directories.
Click to hide internal directories.