예제 #1
0
def check(permission, raw_acl, **context):
    # log.debug('check for %r in %s' % (permission, pformat(context)))
    for state, predicate, permission_set in parse_acl(raw_acl):
        pred_match = predicate(**context)
        perm_match = is_permission_in_set(permission, permission_set)
        if pred_match and perm_match:
            return state
예제 #2
0
 def test_containers(self):
     self.assertTrue(is_permission_in_set('xxx', ('a', 'xxx', 'b')))
     self.assertTrue(is_permission_in_set('xxx', ['a', 'xxx', 'b']))
     self.assertTrue(is_permission_in_set('xxx', set(['a', 'xxx', 'b'])))
     self.assertFalse(is_permission_in_set('xxx', ('a', 'b')))
     self.assertFalse(is_permission_in_set('xxx', ['a', 'b']))
     self.assertFalse(is_permission_in_set('xxx', set(['a', 'b'])))
예제 #3
0
 def test_containers(self):
     self.assertTrue(is_permission_in_set('xxx', ('a', 'xxx', 'b')))
     self.assertTrue(is_permission_in_set('xxx', ['a', 'xxx', 'b']))
     self.assertTrue(is_permission_in_set('xxx', set(['a', 'xxx', 'b'])))
     self.assertFalse(is_permission_in_set('xxx', ('a', 'b')))
     self.assertFalse(is_permission_in_set('xxx', ['a', 'b']))
     self.assertFalse(is_permission_in_set('xxx', set(['a', 'b'])))
예제 #4
0
파일: core.py 프로젝트: leovigna/Flask-ACL
def check(permission, raw_acl, **context):
    # log.debug('check for %r in %s' % (permission, pformat(context)))
    for state, predicate, permission_set in parse_acl(raw_acl):
        pred_match = predicate(**context)
        perm_match = is_permission_in_set(permission, permission_set)
        # log.debug('can %s %r(%s) %r%s' % (
        #     'ALLOW' if state else 'DENY',
        #     predicate, pred_match,
        #     permission_set,
        #     ' -> ' + ('ALLOW' if state else 'DENY') + ' ' + permission if (pred_match and perm_match) else '',
        # ))
        if pred_match and perm_match:
            return state
예제 #5
0
 def test_strings(self):
     self.assertTrue(is_permission_in_set('xxx', 'xxx'))
     self.assertFalse(is_permission_in_set('xxx', 'axxx'))
     self.assertFalse(is_permission_in_set('xxx', 'xxxb'))
예제 #6
0
 def test_callables(self):
     self.assertTrue(is_permission_in_set('xxx', lambda p: True))
     self.assertTrue(is_permission_in_set('xxx', lambda p: 'x' in p))
     self.assertFalse(is_permission_in_set('xxx', lambda p: 'X' in p))
예제 #7
0
 def test_strings(self):
     self.assertTrue(is_permission_in_set('xxx', 'xxx'))
     self.assertFalse(is_permission_in_set('xxx', 'axxx'))
     self.assertFalse(is_permission_in_set('xxx', 'xxxb'))
예제 #8
0
 def test_callables(self):
     self.assertTrue(is_permission_in_set('xxx', lambda p: True))
     self.assertTrue(is_permission_in_set('xxx', lambda p: 'x' in p))
     self.assertFalse(is_permission_in_set('xxx', lambda p: 'X' in p))