Authentication Middleware Refactor #145
Labels
backend
Backend related issues
good first issue
Good for newcomers
help-wanted
Help is wanted
python
Pull requests that update Python code
refactor
Code changes or improvements that do not change code behaviour
Description
This issue aims to refactor the existing Authentication Middleware located in our backend API. In the process we will want to rename the middleware to be more significative and improve exception handling to unexpected errors.
Context
Current authentication Middleware is named
CheckJwtAuthMiddleware
. It serve its purpouse in the early stages of auth in the app but time has come from it to have a more significative name. See CheckJwtAuthMiddleware.Furthermore, we want to improve the unexpected exceptions that we can have in our app ( although they shouldnt exists ). Our current implementation of the dispatch method does the following:
call_next
method redirects the HTTP Request into our endpoints.call_next
the try except block will be trigger ( line 85 ) and a response with 401 Unauthorized will be sent into the client.The objective is to make exception handling more precise. Its not correct to return 401 code if an unexpected error non related to authentication happens. As you can see theres code duplication and the code execution flow can be improved.
How to do it
Testing
The text was updated successfully, but these errors were encountered: