passport-js
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "passport-js" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1da70502763ebd9948031f0131e2b4a7aa8217dffdc21c6e26ff57ba684e72f0. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Add authentication to Express apps using Passport.js. Suitable for implementing Google/GitHub/email sign-in, OAuth flows, session-based auth, or social login scenarios.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: passport-js
description: >-
Add authentication to Express with Passport.js. Use when implementing
login with Google/GitHub/email, OAuth, session auth, or social login.
license: Apache-2.0
compatibility: 'Express, Node.js'
metadata:
author: terminal-skills
version: 1.0.0
category: development
tags: [passport, authentication, oauth, express, social-login]Passport.js
Overview
Passport.js is the most popular auth middleware for Express with 500+ strategies (Google, GitHub, Facebook, SAML, LDAP, local). Session-based by default, works with JWTs too.
Instructions
Step 1: Local Strategy
import passport from 'passport'
import { Strategy as LocalStrategy } from 'passport-local'
import bcrypt from 'bcrypt'
passport.use(new LocalStrategy(
{ usernameField: 'email' },
async (email, password, done) => {
const user = await db.users.findByEmail(email)
if (!user) return done(null, false, { message: 'No account' })
if (!await bcrypt.compare(password, user.passwordHash)) return done(null, false)
return done(null, user)
}
))
passport.serializeUser((user: any, done) => done(null, user.id))
passport.deserializeUser(async (id, done) => done(null, await db.users.findById(id)))
Step 2: Google OAuth
import { Strategy as GoogleStrategy } from 'passport-google-oauth20'
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
callbackURL: '/auth/google/callback',
}, async (accessToken, refreshToken, profile, done) => {
let user = await db.users.findByOAuthId('google', profile.id)
if (!user) user = await db.users.create({
email: profile.emails![0].value,
name: profile.displayName,
oauthProvider: 'google', oauthId: profile.id,
})
return done(null, user)
}))
Step 3: Routes
app.post('/login', passport.authenticate('local', {
successRedirect: '/dashboard', failureRedirect: '/login',
}))
app.get('/auth/google', passport.authenticate('google', { scope: ['profile', 'email'] }))
app.get('/auth/google/callback', passport.authenticate('google', {
successRedirect: '/dashboard', failureRedirect: '/login',
}))
Guidelines
- Hash passwords with bcrypt (cost 12+). Never store plaintext.
- Use express-session with Redis store in production.
- Implement CSRF protection with session-based auth.
- Link accounts: let users connect multiple OAuth providers to one account.
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Passport.js 身份验证的完整实现方案,涵盖本地登录、Google OAuth、路由配置等
- 适用于高频刚需的开发场景,显著提升开发效率
Highlights
- description 明确描述使用场景(Google/GitHub/邮箱登录、OAuth、会话认证、社交登录)
- 触发词精准完整,边界清晰
Highlights
- 文档结构清晰,分步骤说明(Local Strategy、Google OAuth、Routes)
- 包含端到端代码示例,frontmatter 完整
Highlights
- 代码示例工具来源明确(passport-local、passport-google-oauth20、bcrypt),参数正确
- Guidelines 覆盖主要安全实践(密码哈希、会话存储、CSRF 保护)
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 5, 12, 44, 53, 81
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.