README
CleverGo Authorization Middleware
Usage
import (
"clevergo.tech/authz"
"clevergo.tech/clevergo"
)
enforcer, _ := casbin.NewEnforcer("casbin_model.conf", "casbin_policy.csv")
userFunc := func(c *clevergo.Context) (id string, err error) {
// returns the authenticated user ID.
return
}
app := clevergo.New()
app.Use(authz.New(enforcer, userFunc))
Documentation
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnauthorized = clevergo.NewError(http.StatusUnauthorized, errors.New(http.StatusText(http.StatusUnauthorized))) ErrForbidden = clevergo.NewError(http.StatusForbidden, errors.New("you are not allowed to access this page")) )
Errors
Functions ¶
Types ¶
type Option ¶
type Option func(*authorization)
Option is a function that apply on authorization middleware.
func WithSkipper ¶
WithSkipper is an option that set authorization's skipper.