"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/policy/backends/base.py" (13 May 2020, 2308 Bytes) of package /linux/misc/openstack/keystone-17.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "base.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 16.0.1_vs_17.0.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 # not use this file except in compliance with the License. You may obtain
    3 # a copy of the License at
    4 #
    5 #      http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 # Unless required by applicable law or agreed to in writing, software
    8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 # License for the specific language governing permissions and limitations
   11 # under the License.
   12 
   13 import abc
   14 
   15 import keystone.conf
   16 from keystone import exception
   17 
   18 
   19 CONF = keystone.conf.CONF
   20 
   21 
   22 class PolicyDriverBase(object, metaclass=abc.ABCMeta):
   23 
   24     def _get_list_limit(self):
   25         return CONF.policy.list_limit or CONF.list_limit
   26 
   27     @abc.abstractmethod
   28     def enforce(self, context, credentials, action, target):
   29         """Verify that a user is authorized to perform action.
   30 
   31         For more information on a full implementation of this see:
   32         `keystone.policy.backends.rules.Policy.enforce`
   33         """
   34         raise exception.NotImplemented()  # pragma: no cover
   35 
   36     @abc.abstractmethod
   37     def create_policy(self, policy_id, policy):
   38         """Store a policy blob.
   39 
   40         :raises keystone.exception.Conflict: If a duplicate policy exists.
   41 
   42         """
   43         raise exception.NotImplemented()  # pragma: no cover
   44 
   45     @abc.abstractmethod
   46     def list_policies(self):
   47         """List all policies."""
   48         raise exception.NotImplemented()  # pragma: no cover
   49 
   50     @abc.abstractmethod
   51     def get_policy(self, policy_id):
   52         """Retrieve a specific policy blob.
   53 
   54         :raises keystone.exception.PolicyNotFound: If the policy doesn't exist.
   55 
   56         """
   57         raise exception.NotImplemented()  # pragma: no cover
   58 
   59     @abc.abstractmethod
   60     def update_policy(self, policy_id, policy):
   61         """Update a policy blob.
   62 
   63         :raises keystone.exception.PolicyNotFound: If the policy doesn't exist.
   64 
   65         """
   66         raise exception.NotImplemented()  # pragma: no cover
   67 
   68     @abc.abstractmethod
   69     def delete_policy(self, policy_id):
   70         """Remove a policy blob.
   71 
   72         :raises keystone.exception.PolicyNotFound: If the policy doesn't exist.
   73 
   74         """
   75         raise exception.NotImplemented()  # pragma: no cover