How to use the fair.plugin.token.TokenException function in fair

To help you get started, we’ve selected a few fair examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remyzane / fair-api / fair / plugin / token.py View on Github external
def before_request(self, view):
        # get token parameter
        token = view.params.get(PARAM_TOKEN)
        identity = view.params.get(PARAM_IDENTITY)
        if not token:
            raise self.__raise_class(view, 'token_invalid', {'error': 'param_missing', 'parameter': PARAM_TOKEN})
        if not identity:
            raise self.__raise_class(view, 'token_invalid', {'error': 'param_missing', 'parameter': PARAM_IDENTITY})
        # check token
        try:
            self.check(identity, token)
        except TokenException as e:
            raise self.__raise_class(view, 'token_invalid', {'error': str(e)})
github remyzane / fair-api / fair / plugin / token.py View on Github external
from Crypto.Cipher import AES

from fair.parameter import Str
from fair.plugin import Plugin, NOT_NULL
from fair.utility import get_cls_with_path


class TokenException(Exception):
    """All Token exception's parent class"""


class TokenTimestampInvalid(TokenException):
    """Token timestamp invalid, timestamp must be integer"""


class TokenTimeout(TokenException):
    """Token time out"""


class TokenInvalid(TokenException):
    """Token invalid"""


class TokenKeyInvalid(TokenException):
    """Token key must be 16 bytes long"""


PARAM_TOKEN = 'token'
PARAM_IDENTITY = 'identity'
TOKEN_TIME_OUT = 60             # 1 minute
github remyzane / fair-api / fair / plugin / token.py View on Github external
from fair.utility import get_cls_with_path


class TokenException(Exception):
    """All Token exception's parent class"""


class TokenTimestampInvalid(TokenException):
    """Token timestamp invalid, timestamp must be integer"""


class TokenTimeout(TokenException):
    """Token time out"""


class TokenInvalid(TokenException):
    """Token invalid"""


class TokenKeyInvalid(TokenException):
    """Token key must be 16 bytes long"""


PARAM_TOKEN = 'token'
PARAM_IDENTITY = 'identity'
TOKEN_TIME_OUT = 60             # 1 minute


class Token(Plugin):
    """Token check Plugin.

    :cvar function __key_provider: provide token secret key by identity
github remyzane / fair-api / fair / plugin / token.py View on Github external
"""All Token exception's parent class"""


class TokenTimestampInvalid(TokenException):
    """Token timestamp invalid, timestamp must be integer"""


class TokenTimeout(TokenException):
    """Token time out"""


class TokenInvalid(TokenException):
    """Token invalid"""


class TokenKeyInvalid(TokenException):
    """Token key must be 16 bytes long"""


PARAM_TOKEN = 'token'
PARAM_IDENTITY = 'identity'
TOKEN_TIME_OUT = 60             # 1 minute


class Token(Plugin):
    """Token check Plugin.

    :cvar function __key_provider: provide token secret key by identity
            e.g.:
            def key_provider(identity):
                \"""Provide token secret key by identity.
github remyzane / fair-api / fair / plugin / token.py View on Github external
import time
import base64
import binascii
from Crypto.Cipher import AES

from fair.parameter import Str
from fair.plugin import Plugin, NOT_NULL
from fair.utility import get_cls_with_path


class TokenException(Exception):
    """All Token exception's parent class"""


class TokenTimestampInvalid(TokenException):
    """Token timestamp invalid, timestamp must be integer"""


class TokenTimeout(TokenException):
    """Token time out"""


class TokenInvalid(TokenException):
    """Token invalid"""


class TokenKeyInvalid(TokenException):
    """Token key must be 16 bytes long"""


PARAM_TOKEN = 'token'