codejump

JWT Strategies & RBAC

Preview — 3 of 10 questions

Why does a NestJS JWT strategy class extend PassportStrategy(Strategy) rather than Strategy directly?

ATo bypass Passport entirely
BBecause Strategy is abstract and cannot be extended
CPassportStrategy is a mixin that adapts the raw passport-jwt Strategy into an injectable, DI-managed provider and auto-registers it
DTo enable CORS

What exactly does ExtractJwt.fromAuthHeaderAsBearerToken() return when configured as jwtFromRequest?

AThe decoded JWT payload
BA function that extracts the raw token string from the Authorization: Bearer header for each request
CThe signing secret
DA boolean indicating if the header exists

What is the purpose of secretOrKey in the JWT strategy options?

AIt supplies the symmetric secret (or public key) used to verify the token signature
BIt is the username field name
CIt sets the token expiration
DIt defines the cookie name

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.