Documentation ¶
Index ¶
- Variables
- func NewAccessDeniedHandler(Auth AuthInterface, redirectPath string) func(http.ResponseWriter, *http.Request)
- type AuthInterface
- type Authority
- func (authority *Authority) Allow(role string, req *http.Request) bool
- func (authority *Authority) Authorize(roles ...string) func(http.Handler) http.Handler
- func (authority Authority) Handler(rule Rule) roles.Checker
- func (authority *Authority) Middleware(handler http.Handler) http.Handler
- func (authority *Authority) Register(name string, rule Rule)
- type Config
- type Rule
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // AccessDeniedFlashMessage access denied message AccessDeniedFlashMessage = template.HTML("Access Denied!") )
View Source
var ClaimsContextKey utils.ContextKey = "authority_claims"
ClaimsContextKey authority claims key
Functions ¶
func NewAccessDeniedHandler ¶
func NewAccessDeniedHandler(Auth AuthInterface, redirectPath string) func(http.ResponseWriter, *http.Request)
NewAccessDeniedHandler new access denied handler
Types ¶
type AuthInterface ¶
type AuthInterface interface { auth.SessionStorerInterface GetCurrentUser(req *http.Request) interface{} }
AuthInterface auth interface
type Authority ¶
type Authority struct {
*Config
}
Authority authority struct
func (*Authority) Authorize ¶
Authorize authorize specfied roles or authenticated user to access wrapped handler
func (*Authority) Middleware ¶
Middleware authority middleware used to record activity time
type Config ¶
type Config struct { Auth AuthInterface Role *roles.Role AccessDeniedHandler func(w http.ResponseWriter, req *http.Request) }
Config authority config
Click to show internal directories.
Click to hide internal directories.