New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose ExecutionContext inside validate function #8
Comments
@kamilmysliwiec just saw your related issue :) Using
|
Hi, another update. Seems the only context exposed is the HTTP one. In order to use reflectors, this would need the original context. So still, this wouldn't be possible to be fixed with the solution I found. The best solution would be to expose by default the whole context in the validate function, instead of the incoming message |
Ok, after some more research, it's not possible to add the nestjs context into the passportjs context. The reason is that passport expects a request object, nothing else. Finally I used a different approach: use the nestjs/passport module to do authentication. This module sets the user value back in the response object in the context. This now works as expected ;) |
Use the nestjs/passport module to do authentication. This module sets the user value back in the response object in the context. Then in a second guard, I do authorization, using the precalculated user data in the previous guard. This ^ solution sounds like the best possible one 🙂 |
As user I'd like to use the ExecutionContext to take decisions when doing authn/authz with Passport.
Initially I tried to use multiple guards,
This could be easily done exposing the execution context to
this
or somehow passing it to Passport to it makes it available in thevalidate()
function.Otherwise, maybe I could be able to override the newly created
canActivate
function, precreated by the mixin and add my custom logic underneath....The text was updated successfully, but these errors were encountered: