"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/receipt/providers/base.py" (13 May 2020, 1997 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 2018 Catalyst Cloud Ltd
    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 
   17 from keystone import exception
   18 
   19 
   20 class Provider(object, metaclass=abc.ABCMeta):
   21     """Interface description for a Receipt provider."""
   22 
   23     @abc.abstractmethod
   24     def validate_receipt(self, receipt_id):
   25         """Validate a given receipt by its ID and return the receipt_data.
   26 
   27         :param receipt_id: the unique ID of the receipt
   28         :type receipt_id: str
   29         :returns: receipt data as a tuple in the form of:
   30 
   31         (user_id, methods, issued_at, expires_at)
   32 
   33         ``user_id`` is the unique ID of the user as a string
   34         ``methods`` a list of authentication methods used to obtain the receipt
   35         ``issued_at`` a datetime object of when the receipt was minted
   36         ``expires_at`` a datetime object of when the receipt expires
   37 
   38         :raises keystone.exception.ReceiptNotFound: when receipt doesn't exist.
   39         """
   40 
   41     @abc.abstractmethod
   42     def generate_id_and_issued_at(self, receipt):
   43         """Generate a receipt based on the information provided.
   44 
   45         :param receipt: A receipt object containing information about the
   46                         authorization context of the request.
   47         :type receipt: `keystone.models.receipt.ReceiptModel`
   48         :returns: tuple containing an ID for the receipt and the issued at time
   49                   of the receipt (receipt_id, issued_at).
   50         """
   51         raise exception.NotImplemented()  # pragma: no cover