title: NestJs + Passport - JWTStrategy never being called with RS256 tokens
body: <p>I'm trying to implement RS256 JWT tokens in nestjs backend. I followed the example provided in <a href="https://github.com/nestjs/nest/tree/master/sample/19-auth" rel="nofollow noreferrer">nestjs documentation</a>. </p>
  
  <p>In my module I register the <code>JwtModule</code> with my private key:</p>
  
  <pre><code>@Module({
      imports: [
         PassportModule.register({ defaultStrategy: 'jwt' }),
         JwtModule.register({
           secretOrPrivateKey: extractKey(`${process.cwd()}/keys/jwt.private.key`),
           signOptions: {
              expiresIn: 3600,
           },
         }),
      ],
      controllers: [AuthController],
      providers: [AuthService, JwtStrategy, HttpStrategy],
  })
  export class AuthModule {}
  </code></pre>
  
  <p>I'm able to call auth/token endpoint and get the token but when I try to access guarded endpoint I always get 401. </p>
  
  <p>Below you can find my custom <code>JwtStrategy</code>:</p>
  
  <pre><code>@Injectable()
  export class JwtStrategy extends PassportStrategy(Strategy) {
     constructor(private readonly authService: AuthService) {
        super({
            jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
            secretOrKey: extractKey(`${process.cwd()}/keys/jwt.public.key`),
        });
     }
  
     async validate(payload: JwtPayload) {
         console.log('JwtStrategy');
         const user = await this.authService.validateUser(payload);
         if (!user) {
             throw new UnauthorizedException();
         }
         return user;
     }
  }
  </code></pre>
  
  <p>And guarded endpoint:</p>
  
  <pre><code>@Controller('auth')
  export class AuthController {
     constructor(private readonly authService: AuthService) {}
  
     @Get('token')
     async createToken(): Promise&lt;any&gt; {
        return await this.authService.createToken();
     }
  
     @Get('data')
     @UseGuards(AuthGuard())
     findAll() {
        console.log('Guarded endpoint');
        // This route is restricted by AuthGuard
        // JWT strategy
     }
  }
  </code></pre>
  
  <p>I assume that when I call the auth/data I should see in the console at least the "JwtStrategy" string that I log in the validate method. Unfortunately it never shows up. Why the validate method is never called?</p>
  
  <p>Please find the codesandbox below</p>
  
  <p><a href="https://codesandbox.io/s/8n1ojrmp8?fontsize=14" rel="nofollow noreferrer"><img src="https://codesandbox.io/static/img/play-codesandbox.svg" alt="Edit Nest.js JWT Auth"></a></p>