Check if permission is in acl list.
426053
def is_allowed_view(perm):
    """"""

    # Check if permission is in excluded list
    for view in ACL_EXCLUDED_VIEWS:
        module, separator, view_name = view.partition('*')
        if view and perm.startswith(module):
            return False

    # Check if permission is in acl list
    for view in ACL_ALLOWED_VIEWS:
        module, separator, view_name = view.partition('*')
        if separator and not module and not view_name:
            return True
        elif separator and module and perm.startswith(module):
            return True
        elif separator and view_name and perm.endswith(view_name):
            return True
        elif not separator and view == perm:
            return True
    return False
298497
def check_public_permissions(payload):
    """"""
    allowed_public_permissions = ['view', 'add', 'download']
    for perm_type in ['add', 'remove']:
        for perm in payload.get('public', {}).get(perm_type, []):
            if perm not in allowed_public_permissions:
                raise exceptions.PermissionDenied("Permissions for public users are too open")
1369236
def has_permission(cls, user):
        
        # no login is needed, so its always fine
        if not cls.requires_login:
            return True

        # if user is somehow not logged in
        if not user.is_authenticated:
            return False

        # attribute permission_required is mandatory, returns tuple
        perms = cls.get_permission_required()
        # if perms are defined and empty, we skip checking
        if not perms:
            return True

        # get role of user, skip admin role
        role = user.urole.role.name
        if role == cls.ADMIN:
            return True

        # check if at least one permissions is valid
        for permission in perms:
            if cls.check_permission(role, permission):
                return True

        # permission denied
        return False
422698
def check_permission(self, request):
        
        return all((permission.has_permission(request) for permission in self.permission_classes))
257773
def get_permissions(self, user_id):
        """"""
        response = self.request(
            "{0}/{1}/permissions".format(self.version, user_id), {}
        )["data"]
        return {x["permission"] for x in response if x["status"] == "granted"}
516657
def _get_all_permissions(opts):
    ""
    perms = []
    for action in settings.DEFAULT_PERMISSIONS:
        perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name_raw)))
    return perms + list(opts.permissions)
516109
def permission_to_04_acls(permissions):
    
    acls = []
    for perm in permissions:
        if perm.type == "user":
            acls.append((perm.user.id, perm.perm_name))
        elif perm.type == "group":
            acls.append(("group:%s" % perm.group.id, perm.perm_name))
    return acls
246879
function isAuthorized(acl, user) {
    acl = u.str(acl).toUpperCase();
    user = u.str(user).toUpperCase();
    if (user && user === acl) return true;
    if (!aclRe[acl]) {
      aclRe[acl] = reAccess(sessionOpts.acl[acl] || process.env['ACL_' + acl]);
    }
    return aclRe[acl].test(user) || aclRe.ADMIN.test(user);
  }
69008
def validate_permissions(perms):
    
    if not isinstance(perms, (list, tuple)):
        perms = [perms]
    valid_perms = set(PERMISSIONS.values())
    if ALL_PERMISSIONS in perms:
        return perms
    if set(perms) - valid_perms:
        raise ValueError(
            'Invalid ACL permission names. Valid permissions '
            'are: {}'.format(', '.join(valid_perms)))
    return perms
479913
def has_permission(self, permission, obj=None):
        
        if not permission:
            logger.warn("None permission is not allowed")
            return False
        if obj is None:
            return check_permission(permission, self.context)
        return check_permission(permission, api.get_object(obj))
1019612
private Set<Permission> checkPermissions(AAFAuthenticatedUser aau, LocalPermission perm) {
    	if(localLur.fish(aau.getFullName(), perm)) {
//        	aau.setSuper(true);
        	return Permission.ALL;
    	} else {
    		return Permission.NONE;
    	}
    }
177715
private function checkPermission()
    {
        // creates system acl
        $acl = $this->initAcl();

        $identity = $this->getUser()->getIdentity();
        $permissions = $this->initPermissions($identity);
        foreach ($permissions as $key => $p) {
            if ($p && $acl->hasResource($key)) {
                $acl->allow($identity->roles[0], $key, Nette\Security\Permission::ALL);
            }
        }

        // homepage and login page can access everyone
        $acl->allow(Nette\Security\Permission::ALL, 'admin:Homepage', Nette\Security\Permission::ALL);
        $acl->allow(Nette\Security\Permission::ALL, 'admin:Login', Nette\Security\Permission::ALL);

        // superadmin has access to everywhere
        $acl->allow('superadmin', Nette\Security\Permission::ALL, Nette\Security\Permission::ALL);

        $roles = $this->getUser()->getRoles();

        if (!$this->checkRights($acl, $roles)) {
            $this->presenter->flashMessage($this->translation['You do not have a permission to do this operation!'], 'danger');
            $this->redirect(":Admin:Homepage:");
        }
    }
111686
private static boolean hasSelfPermissions(Context context, String... permissions) {
    for (String permission : permissions) {
      if (checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
        return true;
      }
    }
    return false;
  }
784584
def set_collections_acl(self):
        
        acl = [(Allow, 'g:admin', ALL_PERMISSIONS)]
        collections = self.get_collections()
        resources = self.get_resources(collections)
        aces = self._get_least_permissions_aces(resources)
        if aces is not None:
            for ace in aces:
                acl.append(ace)
        acl.append(DENY_ALL)
        self.__acl__ = tuple(acl)
813871
def has_permission(self):
        """"""
        objs = [None]
        if hasattr(self, 'get_perms_objects'):
            objs = self.get_perms_objects()
        else:
            if hasattr(self, 'get_object'):
                try:
                    objs = [self.get_object()]
                except Http404:
                    raise
                except:
                    pass
            if objs == [None]:
                objs = self.get_queryset()

        if (hasattr(self, 'permission_filter_queryset') and
           self.permission_filter_queryset is not False and
           self.request.method == 'GET'):
            if objs != [None]:
                self.perms_filter_queryset(objs)
            return True
        else:
            return check_perms(self.request.user,
                               self.get_permission_required(),
                               objs, self.request.method)
945189
def check_permissions(self, request):
        """"""
        objs = [None]
        if hasattr(self, 'get_perms_objects'):
            objs = self.get_perms_objects()
        else:
            if hasattr(self, 'get_object'):
                try:
                    objs = [self.get_object()]
                except Http404:
                    raise
                except:
                    pass
            if objs == [None]:
                objs = self.get_queryset()
            if len(objs) == 0:
                objs = [None]

        if (hasattr(self, 'permission_filter_queryset') and
           self.permission_filter_queryset is not False and
           self.request.method == 'GET'):
            if objs != [None]:
                self.perms_filter_queryset(objs)
        else:
            has_perm = check_perms(self.request.user,
                                   self.get_permission_required(),
                                   objs, self.request.method)

            if not has_perm:
                msg = self.get_permission_denied_message(
                    default="Permission denied."
                )
                if isinstance(msg, Sequence):
                    msg = msg[0]
                self.permission_denied(request, message=msg)
1132332
def has_permission(self, request):
        """"""
        if not self.object and not self.permission:
            return True

        if not self.permission:
            return request.user.has_perm('{}_{}'.format(
                self.model_permission,
                self.object.__class__.__name__.lower()), self.object
            )

        return request.user.has_perm(self.permission)