コード例 #1
0
ファイル: base.py プロジェクト: wizardsofindustry/quantum-usr
class BaseSubjectIdentificationService(Service):
    finder = ioc.class_property('SubjectFinder')
    x509 = ioc.class_property('X509Service')
    repo = ioc.class_property('PrincipalRepository')

    SubjectDoesNotExist = type('SubjectDoesNotExist', (ObjectDoesNotExist, ),
                               {})
    InvalidPrincipalType = type('InvalidPrincipalType',
                                (UnprocessableEntity, ), {})
    MultipleSubjectsReturned = type('MultipleSubjectsReturned',
                                    (LookupError, ), {})
    UnknownPrincipalType = type('UnknownPrincipalType',
                                (UnprocessableEntity, ), {})

    def associate(self, gsid, principal):
        raise NotImplementedError("Subclasses must override this method.")

    def associate_x509(self, gsid, crt):
        raise NotImplementedError("Subclasses must override this method.")

    def associate_phonenumber(self, gsid, phonenumber):
        raise NotImplementedError("Subclasses must override this method.")

    def associate_idin_bin(self, gsid, bin):
        raise NotImplementedError("Subclasses must override this method.")

    def identify(self, principal):
        raise NotImplementedError("Subclasses must override this method.")

    def identify_x509(self, crt):
        raise NotImplementedError("Subclasses must override this method.")

    def identify_phonenumber(self, phonenumber):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #2
0
class BaseFactorFinder(Finder):
    session = ioc.class_property('DatabaseSessionFactory')
    cipher = ioc.class_property('LocalCipher')

    def get(self, gsid, using):
        raise NotImplementedError("Subclasses must override this method.")

    def has_active_otp(self, kind, gsid):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #3
0
class BaseAuthenticationService(Service):
    factors = ioc.class_property('FactorFinder')
    otp = ioc.class_property('OneTimePasswordService')
    pin = ioc.class_property('PinService')

    SubjectDoesNotExist = type('SubjectDoesNotExist', (Exception, ), {})
    InvalidFactor = type('InvalidFactor', (Exception, ), {})
    SubjectIsBlocked = type('SubjectIsBlocked', (Exception, ), {})

    def authenticate(self, gsid, factors):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #4
0
class BaseIdinService(Service):
    repo = ioc.class_property('TransactionRepository')
    finder = ioc.class_property('TransactionFinder')

    def issuers(self, country=None):
        raise NotImplementedError("Subclasses must override this method.")

    def transaction(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def result(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def update(self, dto):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #5
0
class BaseTransactionCtrl(EndpointCtrl):
    """Generated by SG to serve as an abstract base class for:

        idin.app.ctrl.TransactionCtrl

    This class encapsulates external dependencies (such as the inversion-of-control
    requirements) and specifies the interface for the concrete implementation.
    """
    idin = ioc.class_property('IdinService')

    async def post(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`TransactionCtrl.post()`
        and should be implemented in the following file:

            ./idin/ctrl/transaction/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")

    async def get(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`TransactionCtrl.get()`
        and should be implemented in the following file:

            ./idin/ctrl/transaction/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")

    async def patch(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`TransactionCtrl.patch()`
        and should be implemented in the following file:

            ./idin/ctrl/transaction/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")
コード例 #6
0
class BaseChallengeCtrl(EndpointCtrl):
    """Generated by SG to serve as an abstract base class for:

        challenger.app.ctrl.ChallengeCtrl

    This class encapsulates external dependencies (such as the inversion-of-control
    requirements) and specifies the interface for the concrete implementation.
    """
    service = ioc.class_property('ChallengeService')

    async def post(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`ChallengeCtrl.post()`
        and should be implemented in the following file:

            ./challenger/ctrl/challenge/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")

    async def put(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`ChallengeCtrl.put()`
        and should be implemented in the following file:

            ./challenger/ctrl/challenge/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")
コード例 #7
0
class BaseSubjectFinder(Finder):
    session = ioc.class_property('DatabaseSessionFactory')

    NoChallengesFound = type('NoChallengesFound', (ObjectDoesNotExist,), {})

    def available_challenges(self, gsid):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #8
0
class BaseTransactionFinder(Finder):
    session = ioc.class_property('DatabaseSessionFactory')

    def reference(self, txid):
        raise NotImplementedError("Subclasses must override this method.")

    def result(self, txid, ec):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #9
0
class BaseOneTimePasswordService(Service):
    cipher = ioc.class_property('LocalCipher')
    repo = ioc.class_property('OneTimePasswordRepository')
    factory = ioc.class_property('SubjectFactory')
    finder = ioc.class_property('FactorFinder')

    InvalidOneTimePassword = type('InvalidOneTimePassword', (AuthenticationFailed,), {})
    OneTimePasswordActive = type('OneTimePasswordActive', (DuplicateEntity,), {})

    def enable(self, gsid):
        raise NotImplementedError("Subclasses must override this method.")

    def disable(self, gsid):
        raise NotImplementedError("Subclasses must override this method.")

    def generate(self, kind, gsid, nsid, issuer, force=False):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #10
0
class BaseChallengeService(Service):
    repo = ioc.class_property('ChallengeRepository')
    sms = ioc.class_property('TextMessageService')

    AlreadyChallenged = type('AlreadyChallenged', (DuplicateEntity, ), {})
    ChallengeDoesNotExist = type('ChallengeDoesNotExist',
                                 (ObjectDoesNotExist, ), {})
    InvalidDeliveryChannel = type('InvalidDeliveryChannel',
                                  (UnprocessableEntity, ), {})

    def challenge(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def retry(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def verify(self, dto):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #11
0
class BasePinService(Service):
    repo = ioc.class_property('PinRepository')

    DuplicatePinCode = type('DuplicatePinCode', (DuplicateEntity,), {})

    def createpin(self, gsid, pin=None, force=False):
        raise NotImplementedError("Subclasses must override this method.")

    def verify(self, gsid, pin):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #12
0
class BaseOneTimePasswordCtrl(EndpointCtrl):
    """Generated by SG to serve as an abstract base class for:

        safi.app.ctrl.OneTimePasswordCtrl

    This class encapsulates external dependencies (such as the inversion-of-control
    requirements) and specifies the interface for the concrete implementation.
    """
    otp = ioc.class_property('OneTimePasswordService')
    image = ioc.class_property('QuickResponseImageService')
    finder = ioc.class_property('OneTimePasswordFinder')

    async def post(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`OneTimePasswordCtrl.post()`
        and should be implemented in the following file:

            ./safi/ctrl/onetimepassword/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")
コード例 #13
0
class BasePinRepository(Repository):
    session = ioc.class_property('DatabaseSessionFactory')

    def get(self, gsid):
        raise NotImplementedError("Subclasses must override this method.")

    def exists(self, gsid):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_pin(self, persistable):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #14
0
class BaseTransactionRepository(Repository):
    session = ioc.class_property('DatabaseSessionFactory')

    def persist_tx(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_result(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def setstatus(self, txid, status):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #15
0
class OneTimePasswordEndpoint(sq.interfaces.http.Endpoint):
    """Deserializes, serializes and validates the structure of the input and output
    (requests and response) to its configured URL endpoint, which exposes the
    following functionality:

        Provides an interface to create or regenerate the One-Time Password (OTP) for the Subject identified in the request entity.


    A :class:`OneTimePasswordEndpoint` validates the structure of the request headers,
    URL parameters, query parameters and entity prior to forwarding the
    request to its handler (controller).

    The handler function (e.g., :meth:`~OneTimePasswordCtrl.get()`) may,
    instead of a :class:`~sq.interfaces.http.Response` object, return a tuple
    or a dictionary. The :class:`OneTimePasswordEndpoint` instance will interpret
    these return values as follows:

    -   If the return value is a :class:`dict`, then the endpoint assumes that
        the response code is ``200`` and the object should be included as the
        response body, serialized using the default content type. It is
        considered an error condition if no serializer is specified for
        this content type.
    -   If the return value is a :class:`tuple` with a length of 2, and the
        first element is an :class:`int`, it is considered to hold
        ``(status_code, body)``.
    -   Otherwise, for more granular control over the response, a
        :class:`~sq.interfaces.http.Response` object may be returned.

    If the response body is not a string, it will be serialized using the
    best-matching content type in the client ``Accept`` header. If no
    match is found, the client receives a ``406`` response.

    During serialization, A schema may be selected by :class:`OneTimePasswordEndpoint`
    based on the response status code and content type, if one was defined in
    the OpenAPI definition for this API endpoint.
    """
    pattern = "/generate/otp"
    ctrl = ioc.class_property("OneTimePasswordCtrl")

    #: The mapping below specifies the schema of structured data in the
    #: request body per content type.
    payload = {
        "post": {
            "application/json": {
                "gsid": UUID(required=True),
                "nsid": String(required=True),
                "issuer": String(required=True),
                "force": Boolean(required=False, missing=False)
            }
        }
    }
コード例 #16
0
class BaseChallengeRepository(Repository):
    session = ioc.class_property('DatabaseSessionFactory')

    def persist(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def exists(self, purpose, using, sender, recipient):
        raise NotImplementedError("Subclasses must override this method.")

    def delete(self, purpose, using, sender, recipient):
        raise NotImplementedError("Subclasses must override this method.")

    def get(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_dao(self, dao):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #17
0
class BasePrincipalController(EndpointCtrl):
    """Generated by SG to serve as an abstract base class for:

        usr.app.ctrl.PrincipalController

    This class encapsulates external dependencies (such as the inversion-of-control
    requirements) and specifies the interface for the concrete implementation.
    """
    subject = ioc.class_property('SubjectIdentificationService')

    async def post(self, request, *args, **kwargs):
        """This method specifies the signature for :meth:`PrincipalController.post()`
        and should be implemented in the following file:

            ./usr/ctrl/principal/impl.py
        """
        raise NotImplementedError("Subclasses must override this method.")
コード例 #18
0
class BaseSubjectFinder(Finder):
    session = ioc.class_property('DatabaseSessionFactory')

    def by(self, principals):
        raise NotImplementedError("Subclasses must override this method.")

    def by_email(self, email):
        raise NotImplementedError("Subclasses must override this method.")

    def by_idin_bin(self, bin):
        raise NotImplementedError("Subclasses must override this method.")

    def by_x509_fingerprint(self, fingerprint):
        raise NotImplementedError("Subclasses must override this method.")

    def by_x509_distinguished_names(self, names):
        raise NotImplementedError("Subclasses must override this method.")

    def by_x509_keyid(self, keyid):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #19
0
class IssuerEndpoint(sq.interfaces.http.Endpoint):
    """Deserializes, serializes and validates the structure of the input and output
    (requests and response) to its configured URL endpoint, which exposes the
    following functionality:

        Retrieve a listing of all the banks and their identifiers. The result is grouped by country.


    A :class:`IssuerEndpoint` validates the structure of the request headers,
    URL parameters, query parameters and entity prior to forwarding the
    request to its handler (controller).

    The handler function (e.g., :meth:`~IssuerCtrl.get()`) may,
    instead of a :class:`~sq.interfaces.http.Response` object, return a tuple
    or a dictionary. The :class:`IssuerEndpoint` instance will interpret
    these return values as follows:

    -   If the return value is a :class:`dict`, then the endpoint assumes that
        the response code is ``200`` and the object should be included as the
        response body, serialized using the default content type. It is
        considered an error condition if no serializer is specified for
        this content type.
    -   If the return value is a :class:`tuple` with a length of 2, and the
        first element is an :class:`int`, it is considered to hold
        ``(status_code, body)``.
    -   Otherwise, for more granular control over the response, a
        :class:`~sq.interfaces.http.Response` object may be returned.

    If the response body is not a string, it will be serialized using the
    best-matching content type in the client ``Accept`` header. If no
    match is found, the client receives a ``406`` response.

    During serialization, A schema may be selected by :class:`IssuerEndpoint`
    based on the response status code and content type, if one was defined in
    the OpenAPI definition for this API endpoint.
    """
    pattern = "/issuers/"
    ctrl = ioc.class_property("IssuerCtrl")
コード例 #20
0
ファイル: base.py プロジェクト: wizardsofindustry/quantum-usr
class BasePrincipalRepository(Repository):
    session = ioc.class_property('DatabaseSessionFactory')

    def persist(self, dto):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_email(self, gsid, email):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_phonenumber(self, gsid, phonenumber):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_idin_bin(self, gsid, bin):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_x509_distinguished_names(self, gsid, names):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_x509_fingerprint(self, gsid, fingerprint):
        raise NotImplementedError("Subclasses must override this method.")

    def persist_x509_keyid(self, gsid, keyid):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #21
0
class BaseTextMessageService(Service):
    http = ioc.class_property('RequestFactory')

    def send(self, sender, recipient, message):
        raise NotImplementedError("Subclasses must override this method.")
コード例 #22
0
class BaseOneTimePasswordRepository(Repository):
    cipher = ioc.class_property('LocalCipher')
    session = ioc.class_property('DatabaseSessionFactory')

    def persist_otp(self, persistable):
        raise NotImplementedError("Subclasses must override this method.")