[Flask] Add authentication to auto generated URLs

Christof Verdonck hcmr.verdonck.christof at gmail.com
Wed Mar 1 04:48:07 EST 2017


I am a quiet new developer for both Python and Flask.

To authenticate my Flask application, I am using the Flask extension:
flask-httpauth/ <http://github.com/miguelgrinberg/flask-httpauth/>
To have a secured endpoint, I just add the @auth.login_required decorator
to the @app.route endpoint definition as shown here under:

def secret_page():
    return send_from_directory(app.static_folder, 'secret_page.html')

Now, I have some endpoints that I add dynamically as here under:

    'secret_page_url/', view_func=view_func, methods=['POST', ])

I would like to add also authentication for these URLs but I can't
figure out how this is done.

It seems that the solution I have now, adds authentication on the
adding of the rule instead

of on the accessing of the URL.

Can someone please give me a hint/solution how this is done?

Thank you in advance

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170301/e8e19930/attachment-0001.html>

More information about the Flask mailing list