예제 #1
0
def authenticate(user=None):  # noqa: E501
    """Authenticate

    Authenticate with the API # noqa: E501

    :param user: The user authentication object.
    :type user: dict | bytes

    :rtype: UserAuth
    """
    if connexion.request.is_json:
        user = UserAuth.from_dict(connexion.request.get_json())  # noqa: E501

    credentials = mapUserAuthToCredentials(user)
    auth = ApitaxAuthentication.login(credentials)
    if (not auth):
        return ErrorResponse(status=401, message="Invalid credentials")

    access_token = create_access_token(identity={
        'username': user.username,
        'role': auth['role']
    })
    refresh_token = create_refresh_token(identity={
        'username': user.username,
        'role': auth['role']
    })

    return AuthResponse(status=201,
                        message='User ' + user.username +
                        ' was authenticated as ' + auth['role'],
                        access_token=access_token,
                        refresh_token=refresh_token,
                        auth=UserAuth(username=auth['credentials'].username,
                                      api_token=auth['credentials'].token))
예제 #2
0
def authenticate(user=None):  # noqa: E501
    """Authenticate

    Authenticate with the API # noqa: E501

    :param user: The user authentication object.
    :type user: dict | bytes

    :rtype: AuthResponse
    """
    if connexion.request.is_json:
        user = UserAuth.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
예제 #3
0
def endpoint_catalog(catalog=None):  # noqa: E501
    """Retrieve the endpoint catalog

    Retrieve the endpoint catalog # noqa: E501

    :param catalog: The data needed to get a catalog
    :type catalog: dict | bytes

    :rtype: Response
    """
    if connexion.request.is_json:
        catalog = UserAuth.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
예제 #4
0
def endpoint_catalog(catalog=None):  # noqa: E501
    """Retrieve the endpoint catalog

    Retrieve the endpoint catalog # noqa: E501

    :param catalog: The data needed to get a catalog
    :type catalog: dict | bytes

    :rtype: Response
    """
    if connexion.request.is_json:
        catalog = UserAuth.from_dict(
            connexion.request.get_json())  # noqa: E501

    if (not hasAccess()):
        return redirectUnauthorized()

    driver = LoadedDrivers.getDefaultDriver()
    auth = None
    if (catalog):
        auth = catalog
    return Response(status=200, body=driver.getCatalog(auth))