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


Python security.ALL_PERMISSIONS属性代码示例

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


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

示例1: __init__

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def __init__(self, request):
        self.__acl__ = []
        config = request.registry.settings
        req_url_secret = request.params.get("secret")
        req_secret = request.headers.get("x-channelstream-secret", req_url_secret)

        addr = request.environ["REMOTE_ADDR"]
        if not is_allowed_ip(addr, config):
            log.warning("IP: {} is not whitelisted".format(addr))
            return

        if req_secret:
            max_age = 60 if config["validate_requests"] else None
            request.registry.signature_checker.unsign(req_secret, max_age=max_age)
        else:
            return
        self.__acl__ = [(Allow, Everyone, ALL_PERMISSIONS)] 
开发者ID:Channelstream,项目名称:channelstream,代码行数:19,代码来源:wsgi_security.py

示例2: __init__

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def __init__(self, request):
        exercise_id = request.matchdict['exercise_id']
        self.exercise = request.db.query(Exercise).get(exercise_id)
        if self.exercise is None:
            raise HTTPNotFound(detail='Exercise not found')
        self.exam = self.exercise.exam
        if 'tutorial_ids' in request.matchdict:
            self.tutorial_ids = request.matchdict['tutorial_ids'].split(',')
            if len(self.tutorial_ids)==1 and self.tutorial_ids[0]=='':
                self.tutorial_ids = []
                self.tutorials = []
            else:
                self.tutorials = request.db.query(Tutorial).filter(Tutorial.id.in_(self.tutorial_ids)).all()
        self.__acl__ = [
                (Allow, Authenticated, 'view_points'),
                (Allow, 'group:administrators', ALL_PERMISSIONS),
                ]+[(Allow, 'user:{0}'.format(tutor.id), ('statistics')) for tutor in self.exam.lecture.tutors
                ]+[(Allow, 'user:{0}'.format(assistant.id), ('statistics')) for assistant in self.exam.lecture.assistants
                ] 
开发者ID:muesli-hd,项目名称:muesli,代码行数:21,代码来源:context.py

示例3: test_create_system_user_exists

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def test_create_system_user_exists(self, mock_crypt, mock_trans):
        from ramses import auth
        encoder = mock_crypt.bcrypt.BCRYPTPasswordManager()
        encoder.encode.return_value = '654321'
        config = Mock()
        config.registry.settings = {
            'system.user': 'user12',
            'system.password': '123456',
            'system.email': 'user12@example.com',
        }
        config.registry.auth_model.get_or_create.return_value = (1, False)
        auth.create_system_user(config)
        assert not mock_trans.commit.called
        encoder.encode.assert_called_once_with('123456')
        config.registry.auth_model.get_or_create.assert_called_once_with(
            username='user12',
            defaults={
                'password': '654321',
                'email': 'user12@example.com',
                'groups': ['admin'],
                '_acl': [(Allow, 'g:admin', ALL_PERMISSIONS)],
            }
        ) 
开发者ID:ramses-tech,项目名称:ramses,代码行数:25,代码来源:test_auth.py

示例4: test_create_system_user_created

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def test_create_system_user_created(self, mock_crypt, mock_trans):
        from ramses import auth
        encoder = mock_crypt.bcrypt.BCRYPTPasswordManager()
        encoder.encode.return_value = '654321'
        config = Mock()
        config.registry.settings = {
            'system.user': 'user12',
            'system.password': '123456',
            'system.email': 'user12@example.com',
        }
        config.registry.auth_model.get_or_create.return_value = (
            Mock(), True)
        auth.create_system_user(config)
        mock_trans.commit.assert_called_once_with()
        encoder.encode.assert_called_once_with('123456')
        config.registry.auth_model.get_or_create.assert_called_once_with(
            username='user12',
            defaults={
                'password': '654321',
                'email': 'user12@example.com',
                'groups': ['admin'],
                '_acl': [(Allow, 'g:admin', ALL_PERMISSIONS)],
            }
        ) 
开发者ID:ramses-tech,项目名称:ramses,代码行数:26,代码来源:test_auth.py

示例5: create_system_user

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def create_system_user(config):
    log.info('Creating system user')
    crypt = cryptacular.bcrypt.BCRYPTPasswordManager()
    settings = config.registry.settings
    try:
        auth_model = config.registry.auth_model
        s_user = settings['system.user']
        s_pass = str(crypt.encode(settings['system.password']))
        s_email = settings['system.email']
        defaults = dict(
            password=s_pass,
            email=s_email,
            groups=['admin'],
        )
        if config.registry.database_acls:
            defaults['_acl'] = [(Allow, 'g:admin', ALL_PERMISSIONS)]

        user, created = auth_model.get_or_create(
            username=s_user, defaults=defaults)
        if created:
            transaction.commit()
    except KeyError as e:
        log.error('Failed to create system user. Missing config: %s' % e) 
开发者ID:ramses-tech,项目名称:ramses,代码行数:25,代码来源:auth.py

示例6: set_collections_acl

# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import ALL_PERMISSIONS [as 别名]
def set_collections_acl(self):
        """ Calculate and set ACL valid for requested collections.

        DENY_ALL is added to ACL to make sure no access rules are
        inherited.
        """
        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) 
开发者ID:ramses-tech,项目名称:nefertari,代码行数:17,代码来源:polymorphic.py


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