blob: 294ecc51d0bae7e1a0ad9de8b44a777c6dd49b5f [file] [log] [blame]
Felipe Monteiro31e308e2018-05-22 12:05:10 -07001# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import abc
17
18import six
19
20
21@six.add_metaclass(abc.ABCMeta)
22class RbacAuthority(object):
23 """Class for validating whether a given role can perform a policy action.
24
25 Any class that extends ``RbacAuthority`` provides the logic for determining
26 whether a role has permissions to execute a policy action.
27 """
28
29 @abc.abstractmethod
30 def allowed(self, rule, role):
31 """Determine whether the role should be able to perform the API.
32
33 :param rule: The name of the policy enforced by the API.
34 :param role: The role used to determine whether ``rule`` can be
35 executed.
36 :returns: True if the ``role`` has permissions to execute
37 ``rule``, else False.
38 """