Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultAuthConfig is the default CasbinAuth middleware config. DefaultAuthConfig = AuthConfig{ Skipper: skipper.DefaultSkipper, } )
Functions ¶
func Auth ¶
Auth returns an Auth middleware.
For valid credentials it calls the next handler. For missing or invalid credentials, it sends "401 - Unauthorized" response.
func AuthWithConfig ¶
func AuthWithConfig(config AuthConfig) makross.Handler
AuthWithConfig returns a CasbinAuth middleware with config. See `Auth()`.
func NewEnforcer ¶
NewEnforcer gets an enforcer via CONF, file or DB.
func NewEnforcerSafe ¶
NewEnforcerSafe calls NewEnforcer in a safe way, returns error instead of causing panic.
Types ¶
type AuthConfig ¶
type AuthConfig struct { // Skipper defines a function to skip middleware. Skipper skipper.Skipper // Enforcer CasbinAuth main rule. // Required. Enforcer *casbin.Enforcer }
AuthConfig defines the config for CasbinAuth middleware.
func (*AuthConfig) CheckPermission ¶
func (a *AuthConfig) CheckPermission(c *makross.Context) bool
CheckPermission checks the user/method/path combination from the request. Returns true (permission granted) or false (permission forbidden)
func (*AuthConfig) GetUserName ¶
func (a *AuthConfig) GetUserName(c *makross.Context) string
GetUserName gets the user name from the request. Currently, only HTTP basic authentication is supported