"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/revoke/backends/base.py" (13 May 2020, 2068 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 # Copyright 2012 OpenStack Foundation
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 # not use this file except in compliance with the License. You may obtain
    5 # a copy of the License at
    6 #
    7 #      http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 # License for the specific language governing permissions and limitations
   13 # under the License.
   14 
   15 import abc
   16 import datetime
   17 
   18 from oslo_utils import timeutils
   19 
   20 import keystone.conf
   21 from keystone import exception
   22 
   23 
   24 CONF = keystone.conf.CONF
   25 
   26 
   27 def revoked_before_cutoff_time():
   28     expire_delta = datetime.timedelta(
   29         seconds=CONF.token.expiration + CONF.revoke.expiration_buffer)
   30     oldest = timeutils.utcnow() - expire_delta
   31     return oldest
   32 
   33 
   34 class RevokeDriverBase(object, metaclass=abc.ABCMeta):
   35     """Interface for recording and reporting revocation events."""
   36 
   37     @abc.abstractmethod
   38     def list_events(self, last_fetch=None, token=None):
   39         """return the revocation events, as a list of objects.
   40 
   41         :param last_fetch:   Time of last fetch.  Return all events newer.
   42         :param token: dictionary of values from a token, normalized for
   43                       differences between v2 and v3. The checked values are a
   44                       subset of the attributes of model.TokenEvent
   45         :returns: A list of keystone.revoke.model.RevokeEvent
   46                   newer than `last_fetch.`
   47                   If no last_fetch is specified, returns all events
   48                   for tokens issued after the expiration cutoff.
   49 
   50         """
   51         raise exception.NotImplemented()  # pragma: no cover
   52 
   53     @abc.abstractmethod
   54     def revoke(self, event):
   55         """register a revocation event.
   56 
   57         :param event: An instance of
   58             keystone.revoke.model.RevocationEvent
   59 
   60         """
   61         raise exception.NotImplemented()  # pragma: no cover