Closed gpanainte closed 4 years ago
I'm closing this issue because I have found a workaround based on this suggestion
i have a scenario where authentication is considered as failed only if all 3 strategies fail, eg i am okay whenever 1 of the strategies are successful. one of the strategies is very quick to fail/succeed and always wins the race. is there a way to change this behaviour via flags?
I'm submitting a...
Current behavior
For one of my API endpoints I want to allow access for both public (Unauthenticated users) and authenticated users. My controller looks like this:
The service for the
anonymus
strategy looks like this.The issue I have is that the
anonymous
strategy always "wins" because it is always faster thanjwt
strategy that takes longer because it has to go to the DB to validate user status.Is it possible to have configure the execution order: check if user has a JWT token, if true authenticate by token, else if user has no token allow the request as a public user.
Expected behavior
Execute auth strategies in a predetermined order. Ex: check if user has a JWT token, if true authenticate by token, else if user has no token allow the request as a public user.
Minimal reproduction of the problem with instructions
The code base is private, but if is necessary I could create a small project.
What is the motivation / use case for changing the behavior?
Allow multiple and more sophisticated authentication strategies for the same endpoint.
Environment