Beispiel #1
0
def login_valid():
    """
    Test if api key is valid
    """
    key = request.GET.get('apikey', '')
    if not key and request.json:
        key = request.json.get('apikey', '')
    if not key:
        abort(401, "API key is mandatory")
    for mod in settings.AUTHENTICATION_MODULES:
        if mod.valid_key(key):
            return ret_ok({'message': 'API key is valid'})
    return ret_error('API key is not valid')
Beispiel #2
0
def login_valid():
    """
    Test if api key is valid
    """
    key = request.GET.get('apikey', '')
    if not key and request.json:
        key = request.json.get('apikey', '')
    if not key:
        abort(401, "API key is mandatory")
    for mod in settings.AUTHENTICATION_MODULES:
        if mod.valid_key(key):
            return ret_ok({'message': 'API key is valid'})
    return ret_error('API key is not valid')
Beispiel #3
0
def login_route():
    connection.session.rollback()
    username = request.POST.get('username', '')
    password = request.POST.get('password', '')
    if not username or not password:
        username = request.json.get('username', '')
        password = request.json.get('password', '')
    for mod in settings.AUTHENTICATION_MODULES:
        try:

            key = mod.authenticate(username=username, password=password)
            connection.session.safe_commit()
            logger.info("User %s has successfully authenticated" % username)
            return ret_ok({'apikey': key})
        except AuthenticationFailed:
            pass
    return abort(401, 'Authentication failed')
Beispiel #4
0
def login_route():
    connection.session.rollback()
    username = request.POST.get('username', '')
    password = request.POST.get('password', '')
    if not username or not password:
        username = request.json.get('username', '')
        password = request.json.get('password', '')
    for mod in settings.AUTHENTICATION_MODULES:
        try:

            key = mod.authenticate(username=username, password=password)
            connection.session.safe_commit()
            logger.info("User %s has successfully authenticated" % username)
            return ret_ok({'apikey': key})
        except AuthenticationFailed:
            pass
    return abort(401, 'Authentication failed')
Beispiel #5
0
def version_route():
    """
    Show version
    """
    return ret_ok({'version': str(version)})
Beispiel #6
0
def index_route():
    return ret_ok({'info': 'Renki service management system API'})
Beispiel #7
0
def version_route():
    """
    Show version
    """
    return ret_ok({'version': str(version)})
Beispiel #8
0
def index_route():
    return ret_ok({'info': 'Renki service management system API'})