2

So I have a bunch of error handlers in my flask app and I am NOT using blueprints because of Blueprint 404 errorhandler doesn't activate under blueprint's url prefix

What i have noticed is that 404 will render my custom template but 403 will not. And I am trying to understand 403 errors in my app because during my debugging I get quite a lot of 403 which I am clueless on why.

With that said I am trying to capture and understand 403 errors with the following: (using flask and flask-login + the route for login works without any errors but the others return the JSON listed bellow...)

@app.route('/login')
def login():
    login


@app.errorhandler(401)
def authenticate_user(error):
    return redirect(login), 401


@app.errorhandler(403)
def forbidden(error):
    return render_template('errors/403.html'), 403


@app.errorhandler(404)
def page_not_found(error):
    return render_template('errors/404.html'), 404


@app.errorhandler(500)
def internal_error(error):
    return render_template('errors/500.html'), 500

Thoughts?

This probably doesn't help but the response I usually get on 403 is the JSON of my auth

{"auth": {"authenticated": true, "user": "*******", "roles": "Admin"}}

michael
  • 113
  • 9

0 Answers0