当前位置: 首页>>代码示例>>Python>>正文


Python PermissionSystem.expand_actions方法代码示例

本文整理汇总了Python中trac.perm.PermissionSystem.expand_actions方法的典型用法代码示例。如果您正苦于以下问题:Python PermissionSystem.expand_actions方法的具体用法?Python PermissionSystem.expand_actions怎么用?Python PermissionSystem.expand_actions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.perm.PermissionSystem的用法示例。


在下文中一共展示了PermissionSystem.expand_actions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_permission

# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import expand_actions [as 别名]
    def check_permission(self, action, username, resource, perm):
        if ConfigObj is None:
            self.log.error('configobj package not found')
            return None
        
        if self.authz_file and not self.authz_mtime or \
                os.path.getmtime(self.get_authz_file()) > self.authz_mtime:
            self.parse_authz()
        resource_key = self.normalise_resource(resource)
        self.log.debug('Checking %s on %s', action, resource_key)
        permissions = self.authz_permissions(resource_key, username)
        if permissions is None:
            return None                 # no match, can't decide
        elif permissions == ['']:
            return False                # all actions are denied

        # FIXME: expand all permissions once for all
        ps = PermissionSystem(self.env)
        for deny, perms in groupby(permissions,
                                   key=lambda p: p.startswith('!')):
            if deny and action in ps.expand_actions([p[1:] for p in perms]):
                return False            # action is explicitly denied
            elif action in ps.expand_actions(perms):
                return True            # action is explicitly granted

        return None                    # no match for action, can't decide
开发者ID:trac-ja,项目名称:trac-ja,代码行数:28,代码来源:authz_policy.py

示例2: _expand_perms

# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import expand_actions [as 别名]
 def _expand_perms(self, env):
     permsys = PermissionSystem(env)
     grant = frozenset(permsys.expand_actions(self.grant))
     revoke = frozenset(permsys.expand_actions(self.revoke))
     # Double check ambiguous action lists
     if grant & revoke:
         raise ValueError('Impossible to grant and revoke (%s)' %
                          ', '.join(sorted(grant & revoke)))
     self.grant = grant
     self.revoke = revoke
     self._expanded = True
开发者ID:thimalk,项目名称:bloodhound,代码行数:13,代码来源:perm.py

示例3: get_relevant_permissions

# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import expand_actions [as 别名]
 def get_relevant_permissions(self, policy, username):
     ps = PermissionSystem(self.env)
     relevant_permissions = set(self._required_permissions.itervalues())
     user_permissions = self.get_all_user_permissions(policy, username)
     for doc_type, doc_id, permissions in user_permissions:
         for deny, perms in groupby(permissions,
                                    key=lambda p: p.startswith('!')):
             if deny:
                 for p in ps.expand_actions([p[1:] for p in perms]):
                     if p in relevant_permissions:
                         yield doc_type, doc_id, p, True
             else:
                 for p in ps.expand_actions(perms):
                     if p in relevant_permissions:
                         yield doc_type, doc_id, p, False
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:17,代码来源:security.py

示例4: check_permission

# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import expand_actions [as 别名]
    def check_permission(self, action, username, resource, perm):
        if not self.authz_mtime or os.path.getmtime(self.authz_file) != self.authz_mtime:
            self.parse_authz()
        resource_key = self.normalise_resource(resource)
        self.log.debug("Checking %s on %s", action, resource_key)
        permissions = self.authz_permissions(resource_key, username)
        if permissions is None:
            return None  # no match, can't decide
        elif permissions == []:
            return False  # all actions are denied

        # FIXME: expand all permissions once for all
        ps = PermissionSystem(self.env)
        for deny, perms in groupby(permissions, key=lambda p: p.startswith("!")):
            if deny and action in ps.expand_actions(p[1:] for p in perms):
                return False  # action is explicitly denied
            elif action in ps.expand_actions(perms):
                return True  # action is explicitly granted

        return None  # no match for action, can't decide
开发者ID:pkdevbox,项目名称:trac,代码行数:22,代码来源:authz_policy.py


注:本文中的trac.perm.PermissionSystem.expand_actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。