- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2k
Closed
Description
I'm submitting a...
- Regression
- Bug report
- Feature request
- Documentation issue or request (new chapter/page)
- Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
https://docs.nestjs.com/security/authentication#implementing-passport-jwt
The current nestjs documentation describes the behavior of passport-jwt v4.0.0, this will soon no longer be valid as v5.0.0 (breaking change) is very close to release. This update includes better intergration with @nestjs/jwt, which should be the new default behavior described in the docs.
Expected behavior
The example from NestJs should work with the latest version.
 @Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor() {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      ignoreExpiration: false,
      secretOrKey: jwtConstants.secret,
    });
  }
// Returns error because no jwtDriver has been provided.it currently doesn't work with v5.x.x.
Minimal reproduction of the problem with instructions (includes recomendation)
- follow the documentation of NestJs
- fix the above code example with the patch below
// ... nest js imports
import {JwtStrategyOptions, Strategy, ExtractJwt} from "passport-jwt";
import {NestJsJwtDriver} from "passport-jwt/platform-nestjsjwt";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
    constructor(jwtCore: JwtService) {
      const opts: JwtStrategyOptions = {
        jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
        jwtDriver: new NestJsJwtDriver(jwtCore)
      }
      super(opts);
    }mikenicholson/passport-jwt#238
https://github.com/mikenicholson/passport-jwt/blob/Outternet/master/docs/migrating.md
https://github.com/mikenicholson/passport-jwt/blob/Outternet/master/docs/nestjs.md
What is the motivation / use case for changing the behavior?
The motivation is to have an accurate documentation.
Metadata
Metadata
Assignees
Labels
No labels