Token导航 LogoToken导航

Agent Skill · 研究检索

authentication(身份认证)

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

authentication 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 40,130。

总安装 1,322周安装 54GitHub Stars 6下载 428核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:authentication(身份认证)
来源仓库:https://github.com/mgd34msu/goodvibes-plugin
仓库路径:skills/authentication
安装命令:
npx skills add https://github.com/mgd34msu/goodvibes-plugin --skill authentication
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mgd34msu/goodvibes-plugin --skill authentication

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

authentication 提供与框架无关的身份验证实现,集成安全审计与凭据风险管理。适用于梳理敏感配置、检查鉴权漏洞或生成安全复核清单的场景。支持脚本化验证与错误处理,可与 GoodVibes 精密工具联动。不能将工具输出直接作为最终结论,需人工复核密钥与令牌操作。建议优先采用最小权限原则,并在非生产环境先行测试。

来源仓库内路径:skills/authentication

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/mgd34msu/goodvibes-plugin --skill authenticati…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

authentication 怎么安装?

在终端执行 npx skills add https://github.com/mgd34msu/goodvibes-plugin --skill authentication。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

authentication 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

authentication 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

authentication 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

authentication 用的人多吗?

公开数据是累计安装 1,322 次,近一周安装 54 次,下载 428 次,GitHub 6 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

authentication 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
authentication

身份认证 · 本页

1,3226接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Resources

scripts/
  auth-checklist.sh
references/
  decision-tree.md

Authentication Implementation Workflow

This skill orchestrates complete authentication implementation from discovery through testing. It replaces library-specific skills (clerk, nextauth, lucia, auth0, firebase-auth, supabase-auth, passport) with a unified workflow that adapts to your stack.

When to Use This Skill

Use when implementing:

  • User login and sign-up flows
  • Session management (cookies, JWT, server-side sessions)
  • OAuth integration (Google, GitHub, etc.)
  • Protected routes and API endpoints
  • Middleware-based authentication
  • Role-based access control (RBAC)
  • Token refresh mechanisms
  • Password reset flows

Prerequisites

Before starting:

  1. Understand project framework (Next.js, Remix, Express, etc.)
  2. Have database schema planned (if using database-backed auth)
  3. Know authentication approach (managed service vs self-hosted)
  4. Access to environment variable configuration

Workflow Steps

Step 1: Discovery

Use discover to understand existing authentication patterns:

discover:
  queries:
    - id: existing-auth
      type: grep
      pattern: "(useAuth|getSession|withAuth|requireAuth|protect|authenticate)"
      glob: "**/*.{ts,tsx,js,jsx}"
    - id: middleware-files
      type: glob
      patterns:
        - "**/middleware.{ts,js}"
        - "**/auth/**/*.{ts,js}"
        - "**/_middleware.{ts,js}"
    - id: session-handling
      type: grep
      pattern: "(session|jwt|token|cookie)"
      glob: "**/*.{ts,tsx,js,jsx}"
    - id: protected-routes
      type: grep
      pattern: "(protected|private|requireAuth|withAuth)"
      glob: "**/*.{ts,tsx,js,jsx}"
  verbosity: files_only

What to look for:

  • Existing auth hooks, utilities, or middleware
  • Session storage mechanism (cookies, localStorage, server-side)
  • Protected route patterns
  • Auth provider setup (if using third-party)

Decision Point: If auth is already partially implemented, read existing files to understand the pattern before extending it.

Step 2: Detect Stack

Use detect_stack to determine framework and identify auth approach:

detect_stack:
  path: "."

Framework Detection:

  • Next.js (App Router): Use middleware.ts + Server Actions + cookies
  • Next.js (Pages Router): Use getServerSideProps + API routes + NextAuth
  • Remix: Use loader/action auth + session cookies
  • Express/Fastify: Use middleware + session store
  • tRPC: Use context + middleware
  • GraphQL: Use context + directives

Consult Decision Tree: Read references/decision-tree.md to choose between managed (Clerk, Auth0), self-hosted (NextAuth, Lucia), or serverless (Supabase Auth) based on framework and requirements.

Step 3: Implementation Planning

Based on framework and decision tree, plan which files to create/modify:

Common Files Needed:

  1. Middleware (middleware.ts, auth.middleware.ts)

- Intercept requests - Verify authentication status - Redirect unauthenticated users

  1. Auth Utilities (lib/auth.ts, utils/auth.ts)

- Session creation/validation - Token generation/verification - Password hashing (bcrypt, argon2)

  1. Auth API Routes (/api/auth/login, /api/auth/signup, /api/auth/logout)

- Handle authentication requests - Set session cookies - Return auth state

  1. Protected Route Wrappers (withAuth, requireAuth)

- HOCs or server utilities - Check auth before rendering - Redirect or return 401

  1. Client Hooks (useAuth, useSession)

- Access current user - Manage client-side auth state - Trigger login/logout

Framework-Specific Patterns:

Next.js App Router:

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
  const token = request.cookies.get('session')?.value;

  if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
    return NextResponse.redirect(new URL('/login', request.url));
  }

  return NextResponse.next();
}

export const config = {
  matcher: ['/dashboard/:path*', '/api/:path*']
};

Remix:

// app/utils/session.server.ts
import { createCookieSessionStorage } from '@remix-run/node';

const { getSession, commitSession, destroySession } =
  createCookieSessionStorage({
    cookie: {
      name: '__session',
      httpOnly: true,
      secure: process.env.NODE_ENV === 'production',
      secrets: [process.env.SESSION_SECRET],
      sameSite: 'lax'
    }
  });

export { getSession, commitSession, destroySession };

Express:

// middleware/auth.ts
import jwt from 'jsonwebtoken';
import type { Request, Response, NextFunction } from 'express';

export function requireAuth(req: Request, res: Response, next: NextFunction) {
  const token = req.headers.authorization?.replace(/^bearer\s+/i, '');

  if (!token) {
    return res.status(401).json({ error: 'Unauthorized' });
  }

  try {
    const payload = jwt.verify(token, process.env.JWT_SECRET!);
    req.user = payload;
    next();
  } catch (err) {
    return res.status(401).json({ error: 'Invalid token' });
  }
}

Step 4: Write Configuration and Core Files

Use precision_write in batch mode to create auth infrastructure:

precision_write:
  files:
    - path: "middleware.ts"
      content: |
        # Framework-specific middleware (see patterns above)
    - path: "lib/auth.ts"
      content: |
        # Session validation, token generation
    - path: "app/api/auth/login/route.ts"
      content: |
        # Login endpoint implementation
    - path: "app/api/auth/signup/route.ts"
      content: |
        # Sign-up endpoint with validation
    - path: "app/api/auth/logout/route.ts"
      content: |
        # Logout and session cleanup
  verbosity: minimal

CRITICAL: No Placeholders

  • Implement full validation (zod, yup, etc.)
  • Include proper error handling
  • Hash passwords with bcrypt/argon2
  • Use secure session configuration
  • Add CSRF protection where applicable

Step 5: Install Dependencies

Use precision_exec to install required packages:

precision_exec:
  commands:
    # For JWT-based auth
    - cmd: "npm install jsonwebtoken bcryptjs"
    - cmd: "npm install -D @types/jsonwebtoken @types/bcryptjs"

    # For session-based auth
    - cmd: "npm install express-session connect-redis"
    - cmd: "npm install -D @types/express-session"

    # For managed services
    - cmd: "npm install @clerk/nextjs"  # Clerk
    - cmd: "npm install next-auth"      # NextAuth
    - cmd: "npm install better-auth"    # Better Auth (replaces deprecated Lucia)
  verbosity: minimal

Run Database Migrations (if needed):

precision_exec:
  commands:
    - cmd: "npx prisma migrate dev --name add_user_auth"
      timeout_ms: 60000
    - cmd: "npx prisma generate"
  verbosity: standard

Step 6: Security Verification

Use analysis-engine tools to verify security:

1. Scan for Hardcoded Secrets:

scan_for_secrets:
  paths:
    - "lib/auth.ts"
    - "app/api/auth/**/*.ts"
    - "middleware.ts"

Expected Result: Zero secrets found. All API keys, JWT secrets, and credentials must be in .env files.

If secrets found:

  • Move to .env or .env.local
  • Use process.env.VAR_NAME to access
  • Add to .gitignore if not already present

2. Audit Environment Variables:

env_audit:
  check_documented: true

Expected Result: All auth-related env vars documented in .env.example or README.

Required Variables (typical):

  • JWT_SECRET or SESSION_SECRET
  • DATABASE_URL (if using database)
  • OAuth credentials (GOOGLE_CLIENT_ID, GITHUB_CLIENT_SECRET, etc.)
  • NEXTAUTH_URL and NEXTAUTH_SECRET (for NextAuth)

3. Validate Implementation:

# Use precision_grep to validate critical security patterns
precision_grep:
  queries:
    - id: password_hashing
      pattern: "bcrypt|argon2|hashPassword"
      path: "lib"
      glob: "**/*.ts"
    - id: httpOnly_cookies
      pattern: "httpOnly.*true|httpOnly:\s*true"
      path: "."
      glob: "**/*.ts"
    - id: csrf_protection
      pattern: "csrf|CsrfToken|verifyCsrfToken"
      path: "."
      glob: "**/*.ts"
  output:
    format: "count_only"

Step 7: Protected Routes Implementation

Create route protection utilities:

Server-Side Protection (Next.js App Router):

// lib/auth.ts
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

export async function requireAuth() {
  const cookieStore = await cookies();
  const session = cookieStore.get('session')?.value;

  if (!session) {
    redirect('/login');
  }

  const user = await validateSession(session);
  if (!user) {
    redirect('/login');
  }

  return user;
}

Client-Side Hook (React):

// hooks/useAuth.ts
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';

export function useAuth(options?: { redirectTo?: string }) {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);
  const router = useRouter();

  useEffect(() => {
    fetch('/api/auth/me')
      .then(res => res.ok ? res.json() : null)
      .then(data => {
        if (!data && options?.redirectTo) {
          router.push(options.redirectTo);
        } else {
          setUser(data);
        }
      })
      .finally(() => setLoading(false));
  }, [options?.redirectTo, router]);

  return { user, loading };
}

Apply to Routes:

Use precision_edit to add auth checks to existing routes:

precision_edit:
  files:
    - path: "app/dashboard/page.tsx"
      edits:
        - find: "export default function DashboardPage()"
          replace: |
            export default async function DashboardPage() {
              const user = await requireAuth();
          hints:
            near_line: 1

Step 8: Test Implementation

Use suggest_test_cases to generate auth-specific test scenarios:

suggest_test_cases:
  file: "lib/auth.ts"
  category: "authentication"

Expected Test Cases:

  • Valid login with correct credentials
  • Login failure with incorrect password
  • Sign-up with valid data
  • Sign-up with duplicate email
  • Protected route redirects unauthenticated users
  • Session token refresh
  • Logout clears session
  • CSRF token validation
  • Password reset flow

Run Validation Script:

bash scripts/auth-checklist.sh .

Expected Exit Code: 0 (all checks pass)

Manual Testing Checklist:

  1. Sign up new user
  2. Verify password is hashed in database
  3. Log in with credentials
  4. Access protected route (should succeed)
  5. Log out
  6. Access protected route (should redirect to login)
  7. Test OAuth flow (if implemented)
  8. Verify session persists across page reloads
  9. Test token expiration and refresh

Common Patterns by Framework

Next.js (App Router)

Session Management:

  • Use cookies() from 'next/headers'
  • Set httpOnly, secure, sameSite cookies
  • Validate in middleware.ts and Server Components

Protected Routes:

  • Server-side: await requireAuth() in page/layout
  • Client-side: useAuth() hook with redirectTo
  • API routes: check cookies in route handlers

OAuth:

  • Use NextAuth for simplicity
  • Or implement manual OAuth flow with redirect URIs

Remix

Session Management:

  • Use createCookieSessionStorage
  • Validate in loaders
  • Commit session in actions

Protected Routes:

  • Check session in loader, throw redirect() if unauthenticated
  • Use getSession() utility consistently

OAuth:

  • Use remix-auth strategies
  • Handle callbacks in dedicated routes

Express/Fastify

Session Management:

  • Use express-session + Redis store
  • Or JWT tokens in Authorization header

Protected Routes:

  • Middleware functions: requireAuth, optionalAuth
  • Apply to specific routes or globally

OAuth:

  • Use passport.js strategies
  • Configure serialize/deserialize user

Error Handling

Follow error-recovery protocol for auth failures:

Login Failures

try {
  const user = await validateCredentials(email, password);
  await createSession(user.id);
  return { success: true };
} catch (err) {
  if (err instanceof InvalidCredentialsError) {
    // Don't leak whether email exists
    return { error: 'Invalid email or password' };
  }
  if (err instanceof UserLockedError) {
    return { error: 'Account locked. Contact support.' };
  }
  throw err; // Unexpected error
}

Session Validation Failures

export async function validateSession(token: string) {
  try {
    const payload = jwt.verify(token, process.env.JWT_SECRET!);
    return await getUserById(payload.userId);
  } catch (err) {
    if (err instanceof jwt.TokenExpiredError) {
      return null; // Let caller handle (refresh or re-login)
    }
    if (err instanceof jwt.JsonWebTokenError) {
      return null; // Invalid token
    }
    throw err; // Unexpected error
  }
}

Database Errors

try {
  const user = await db.user.create({
    data: { email, passwordHash }
  });
} catch (err) {
  if (err.code === 'P2002') {
    // Prisma unique constraint violation
    return { error: 'Email already registered' };
  }
  throw err;
}

Security Checklist

Before marking implementation complete:

  • Passwords hashed with bcrypt (cost 10+) or argon2
  • Session tokens are random (crypto.randomBytes) or signed JWT
  • Cookies are httpOnly, secure (in prod), sameSite: 'lax' or 'strict'
  • CSRF protection enabled (for cookie-based auth)
  • Rate limiting on login/signup endpoints
  • Input validation on all auth endpoints
  • No sensitive data in error messages
  • Environment variables documented in.env.example
  • No hardcoded secrets in source code
  • Session expiration configured (1-7 days typical)
  • Logout clears all auth tokens/sessions
  • OAuth redirect URIs whitelisted

References

  • references/decision-tree.md - Managed vs self-hosted vs serverless comparison
  • .goodvibes/memory/patterns.json - Project-specific auth patterns
  • scripts/auth-checklist.sh - Automated validation script

Troubleshooting

"Session not persisting across requests"

Likely Causes:

  • Cookie not being set (check response headers)
  • httpOnly preventing client-side access (expected)
  • sameSite: 'strict' blocking cross-origin (use 'lax')
  • Cookie domain mismatch

Fix:

  1. Check cookie configuration in auth code
  2. Verify cookies are in response: precision_exec: {cmd: "curl -v localhost:3000/api/auth/login"}
  3. Ensure middleware reads cookies correctly

"JWT token invalid after server restart"

Likely Causes:

  • JWT_SECRET changes between restarts
  • Secret not in.env file
  • Different secret in different environments

Fix:

  1. Move JWT_SECRET to.env: JWT_SECRET=<random-256-bit-hex>
  2. Generate with: openssl rand -hex 32
  3. Never commit.env to git

"OAuth callback fails with redirect_uri_mismatch"

Likely Causes:

  • Callback URL not whitelisted in OAuth provider dashboard
  • http vs https mismatch
  • Port number missing

Fix:

  1. Check OAuth provider settings
  2. Add callback URL exactly as it appears in error
  3. For local dev, use http://localhost:3000/api/auth/callback/google (example)

"Protected routes not redirecting"

Likely Causes:

  • Middleware not configured correctly
  • Matcher pattern doesn't match route
  • Session validation failing silently

Fix:

  1. Check middleware.ts config.matcher
  2. Add logging to middleware to verify it's running
  3. Test session validation independently

Next Steps After Implementation

  1. Add role-based access control (RBAC):

- Add role field to User model - Create permission checking utilities - Protect admin routes

  1. Implement password reset:

- Generate reset tokens - Send email with reset link - Validate token and update password

  1. Add email verification:

- Generate verification tokens on signup - Send verification email - Verify token and mark user as verified

  1. Set up refresh tokens:

- Issue short-lived access tokens (15 min) - Issue long-lived refresh tokens (7 days) - Rotate refresh tokens on use

  1. Add audit logging:

- Log all login attempts (success and failure) - Track IP addresses and user agents - Monitor for suspicious activity

Summary

This workflow provides:

  • Framework-agnostic authentication implementation
  • Security-first approach with validation
  • Integration with GoodVibes precision tools
  • Automated verification via scripts
  • Error handling and troubleshooting

Follow each step sequentially, using precision tools for all file operations and validation.

平台分布

Codex

33.8%
按下载量换算145

Claude

30.78%
按下载量换算132

Cursor

17.37%
按下载量换算74

Gemini CLI

9.65%
按下载量换算41

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills