Recall & Review
beginner
What is Passport.js used for in a NestJS application?
Passport.js is used to handle user authentication in a NestJS app. It helps verify user identity with strategies like local login or OAuth.
Click to reveal answer
beginner
How do you add Passport.js to a NestJS project?
You install the passport and passport strategy packages, then import PassportModule in your module to use Passport features.Click to reveal answer
beginner
What is a Passport strategy?
A strategy is a way to authenticate users, like checking username/password (local) or using Google OAuth. You tell Passport which strategy to use.
Click to reveal answer
intermediate
How does NestJS connect Passport strategies to routes?
NestJS uses guards like AuthGuard('local') to protect routes. Guards run the Passport strategy before allowing access.
Click to reveal answer
intermediate
What role does the AuthService play in Passport.js integration?
AuthService contains the logic to validate users, like checking credentials against a database. Passport calls it during authentication.
Click to reveal answer
Which NestJS module must you import to use Passport.js?
✗ Incorrect
PassportModule provides the integration layer for Passport.js in NestJS.
What does the 'local' strategy in Passport.js do?
✗ Incorrect
The 'local' strategy checks username and password credentials.
How do you protect a NestJS route with Passport authentication?
✗ Incorrect
The @UseGuards decorator applies Passport's AuthGuard to protect routes.
What does AuthService typically do in Passport integration?
✗ Incorrect
AuthService contains the logic to check if user credentials are valid.
Which method does Passport call to validate a user in a local strategy?
✗ Incorrect
The validate() method checks user credentials and returns user data if valid.
Explain how Passport.js integrates with NestJS to authenticate users.
Think about modules, services, strategies, and guards working together.
You got /5 concepts.
Describe the steps to protect a NestJS route using Passport's local strategy.
Focus on strategy setup and route guard usage.
You got /5 concepts.