【发布时间】:2021-06-11 19:42:25
【问题描述】:
我正在关注https://www.codemag.com/Article/2001081/Nest.js-Step-by-Step-Part-3-Users-and-Authentication 在nestJS 中使用passport 实现jwt,一切都按预期工作,但我对这种方法有一个澄清,如果我们使用UseGuards(@AuthGurads()),应用程序知道使用passportstrategy验证令牌并调用 validate 方法以进一步进行,但是为什么护照策略知道正确的 jwt 策略类来选择调用 validate 方法,没有明确提到我们要求护照策略使用 jwtStrategy 类,它是不是默认导出,但在验证令牌后仍然如何为 validate 方法调用正确的 JwtStrategy 类?
【问题讨论】:
-
docs.nestjs.com/security/authentication#login-route
we are using an AuthGuard that @nestjs/passportautomatically provisioned for us when we extended the passport-local strategy.
标签: authentication jwt passport.js nestjs passport-jwt