Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SameAssignedRoles ¶
SameAssignedRoles is an equality test for roles that have been assigned.
func SameRoleDefinitions ¶
SameRoleDefinitions is an equality test for Roles.
Types ¶
type Enforcer ¶
type Enforcer struct { Roles RoleList AuthorizationChecker func(http.ResponseWriter, *http.Request, Role) error // contains filtered or unexported fields }
Enforcer is a xhttp handler that is used to make sure that access to a server endpoint is made with the proper roles and/or permissions.
func Enforce ¶
func Enforce(r RoleList, AuthorizationChecker func(http.ResponseWriter, *http.Request, Role) error) Enforcer
Enforce returns a role-based access checking xhttp.Handler. As in the Rolelist AccessGranted method, it takes as argument a function that checks if a user has the proper roles.
type Role ¶
type Role struct { UID string Name string Permissions map[string]interface{} Duration time.Duration CreatedAt time.Time AssignedOn time.Time ContextKey *contextKey `json:"-"` }
Role defines a user role. User roles can be used to grant access to parts of an application to a selection of credited clients. If permissions are added, permissions will have to be checked.
type RoleList ¶
type RoleList struct { Roles map[*contextKey]Role AssignRole func(http.ResponseWriter, *http.Request, Role) error // contains filtered or unexported fields }
RoleList defines a list of roles that may be enforced simultaneously.
func NewRoleList ¶
func NewRoleList(AssignFunc func(http.ResponseWriter, *http.Request, Role) error, roles ...Role) RoleList
NewRoleList creates a RoleList. The first argument is the function used to assign roles in response to a http request to be granted said roles.