0
0
NestJSframework~5 mins

Passport.js integration in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AUserModule
BAuthModule
CHttpModule
DPassportModule
What does the 'local' strategy in Passport.js do?
AAuthenticates using username and password
BAuthenticates using Google OAuth
CHandles session management
DEncrypts user passwords
How do you protect a NestJS route with Passport authentication?
AUse @UseGuards(AuthGuard('strategyName')) decorator
BCall passport.authenticate() inside the controller
CAdd PassportModule to the controller
DUse @Injectable() decorator
What does AuthService typically do in Passport integration?
AManages database connections
BValidates user credentials
CHandles HTTP requests
DRenders views
Which method does Passport call to validate a user in a local strategy?
Alogin()
Bauthenticate()
Cvalidate()
Dregister()
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.