Fail fast on permission check in case of invalid identity

This commit is contained in:
Denis Arh
2019-03-13 07:18:01 +01:00
parent 52d9c95f32
commit 1c74f30b19
+5
View File
@@ -43,6 +43,11 @@ func (r *resources) identity() uint64 {
// IsAllowed function checks granted permission for specific resource and operation. Permission checks on
// global level are not allowed and will always return Deny.
func (r *resources) Check(resource string, operation string, fallbacks ...CheckAccessFunc) Access {
// Number one check, do we have a valid identity?
if !auth.GetIdentityFromContext(r.ctx).Valid() {
return Deny
}
parts := strings.Split(resource, delimiter)
// Permission check on global level is not allowed.