Add 'dis_grant' command
This commit is contained in:
parent
6bf6d3a8f5
commit
8b55fd74f9
10 changed files with 161 additions and 18 deletions
|
|
@ -48,6 +48,24 @@ func (g grantDeny) Denied() string {
|
|||
return string(g)
|
||||
}
|
||||
|
||||
// AllPermissions returns a new permission that checks if all the given permissions are set
|
||||
func AllPermissions(clauses ...Permission) Permission {
|
||||
return func(user *AuthUser, r *http.Request) (ok Grant, err error) {
|
||||
for _, clause := range clauses {
|
||||
perm, err := clause.Permit(user, r)
|
||||
if err != nil {
|
||||
return perm, err
|
||||
}
|
||||
if !perm.Granted() {
|
||||
return perm, nil
|
||||
}
|
||||
}
|
||||
|
||||
// everything was fine
|
||||
return grantAllow{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
var errPermissionPanic = errors.New("permission: panic()")
|
||||
|
||||
// Permit checks if the given user has this permission.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue