@action(route="/radiovis/api/<secret>/check_auth")
@only_orga_admin_user()  # To prevent call from IO
@json_only()
def radiovis_api_check_auth(request, secret):

    if secret != config.API_SECRET:
        abort(404)
        return

    user = request.form.get('username')
    password = request.form.get('password')
    ip = request.form.get('ip')

    # Find the station
    id = user.split('.')[0]

    object = Station.query.filter_by(id=int(id)).first()

    if not object:
        return {'result': False, 'error': 'No station'}

    if object.stomp_username != user:
        return {'result': False, 'error': 'Wrong username'}

    if object.random_password != password:
        return {'result': False, 'error': 'Wrong password'}

    if ip:
        allowd = False

        for subnetAllowed in object.ip_allowed.split(','):
            if addressInNetwork(ip, subnetAllowed):
                allowd = True
                break

        if not allowd:
            return {'result': False, 'error': 'IP not allowed'}

    return {'result': True}
Api call to authenticate a station
dataset/ETHPy150Open ebu/radiodns-plugit/RadioDns-PlugIt/radiovis/actions.py/radiovis_api_check_auth