Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MustAuthenticate is returned if authentication is required. MustAuthenticate = 0 // AccessAllowed is returned if the user has access to the resource. AccessAllowed = 1 // AccessDenied is returned if the user has no access to the resource. AccessDenied = 2 // AnonymousAccess is returned if the access is authorized for anonymous access. AnonymousAccess = 1 // IdentifiedAccess is returned if the access is authorized for an identified user. IdentifiedAccess = 2 )
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
func Setup(c *caddy.Controller) error
Setup parses the Casbin configuration and returns the middleware handler.
Types ¶
type Authorizer ¶
type Authorizer struct {
Next httpserver.Handler
Enforcer *casbin.Enforcer
Realm string
PasswordCheck authfile.IAuthenticationService
}
Authorizer is a middleware for filtering clients based on their ip or country's ISO code.
func (*Authorizer) CheckEnforce ¶
func (a *Authorizer) CheckEnforce(user, path, method string) (int, bool)
CheckEnforce verifies if the user has access to the resource. If no username is given, the check will be against "nobody" only.
func (*Authorizer) CheckPermission ¶
func (a *Authorizer) CheckPermission(r *http.Request) int
CheckPermission checks the user/method/path combination from the request. Returns true (permission granted) or false (permission forbidden)
func (*Authorizer) GetUserName ¶
func (a *Authorizer) GetUserName(r *http.Request) string
GetUserName gets the user name from the request. Currently, only HTTP basic authentication is supported
func (Authorizer) ServeHTTP ¶
func (a Authorizer) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
ServeHTTP serves the request.
Click to show internal directories.
Click to hide internal directories.