Flask-Middleware / flask-security

Quick and simple security for Flask applications
MIT License
622 stars 154 forks source link

Add debug logging flag #975

Closed mmillmore closed 2 weeks ago

mmillmore commented 1 month ago

We have faced situations where we have a silly error in our code (e.g. wrong permission name), and are struggling to find what is going wrong because it's hard to spot, and the errors that come out of the system are (intentionally) opaque. It would be good if we had a flag we could set to turn on more verbose logging of what is going on, e.g. this user doesn't have the right permission, and show their permission list. When a user can't log in, in debug mode tell us if the user is not found or the password is wrong, and so on

jwag956 commented 1 month ago

Have you tried defining your own unauthz_handler: https://flask-security-too.readthedocs.io/en/stable/api.html#flask_security.Security.unauthz_handler

you get which decorator and what args (and you of course have the entire request context) - log what you need then call default_unauthz_handler() to finish the request.

mmillmore commented 1 month ago

Thanks for the tip. I'll give that a go

jwag956 commented 2 weeks ago

Please reopen if you think of additional enhancements.