Token导航 LogoToken导航

Agent Skill · 前端设计

auth-expert(认证专家)

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

auth-expert 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 7,853。

总安装 336周安装 14GitHub Stars 9下载 112核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/yuniorglez/gemini-elite-core --skill auth-expert

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于辅助安全审计、权限检查和认证流程分析。适合梳理敏感配置、检查依赖风险或生成安全复核清单。使用时不能将工具输出直接当作最终结论,需人工复核。安装命令:npx skills add https://github.com/yuniorglez/gemini-elite-core --skill auth-expert。

涉及密钥或生产系统时应先确认最小权限和操作边界。

来源仓库内路径:skills/auth-expert

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

auth-expert 怎么安装?

在终端执行 npx skills add https://github.com/yuniorglez/gemini-elite-core --skill auth-expert。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

auth-expert 支持哪些 AI 工具?

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

auth-expert 需要什么权限?

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

auth-expert 是免费的吗?

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

auth-expert 用的人多吗?

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

auth-expert 安全吗?

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

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

值得选的地方

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

先想清楚的地方

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

适不适合你

更适合

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

不太适合

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

前端设计类 Skill 对比

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

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
auth-expert

认证专家 · 本页

3369接触敏感数据未明确通过

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

SKILL.md 原文

🔑 Skill: auth-expert (v2.0.0)

🌟 Overview & Vision 2026

This skill provides a deep-dive into Auth.js v5, the successor to NextAuth.js. It is specifically optimized for the Next.js 16.1.1 App Router, React 19.2 Server Actions, and Edge Runtime constraints.

In 2026, authentication is no longer just about a login form; it's about a unified session architecture that works across Server Components, Client Components, Middleware, and Server Actions without performance trade-offs.


📚 Table of Contents

  1. Core Architecture: The Dual-Config Pattern
  2. Quick Start: The 5-Minute Setup
  3. Universal Auth: The auth() Protocol
  4. Route Protection & Middleware
  5. React 19 Server Actions & Authentication
  6. The "Do Not" List (Common Pitfalls)
  7. Security Hardening Checklist
  8. Advanced Patterns: Types & Extensibility
  9. Deep Dives (References)

🏗️ Core Architecture: The Dual-Config Pattern

To avoid "Module not found" errors in the Edge Runtime (Middleware), Auth.js v5 requires a split configuration.

1. Edge-Compatible Logic (auth.config.ts)

This file contains only logic that can run on the Edge. Never import database adapters or heavy Node.js libraries here.

import type { NextAuthConfig } from "next-auth";
import GitHub from "next-auth/providers/github";

// This is the base config for Middleware and Edge functions
export const authConfig = {
  providers: [
    GitHub({
      clientId: process.env.AUTH_GITHUB_ID,
      clientSecret: process.env.AUTH_GITHUB_SECRET,
    }),
  ],
  callbacks: {
    authorized({ auth, request: { nextUrl } }) {
      const isLoggedIn = !!auth?.user;
      const isOnDashboard = nextUrl.pathname.startsWith("/dashboard");

      if (isOnDashboard) {
        if (isLoggedIn) return true;
        return false; // Redirect unauthenticated users to login
      }
      return true;
    },
  },
} satisfies NextAuthConfig;

2. Full Logic (auth.ts)

This file imports authConfig and adds the database adapter (Node.js runtime).

import NextAuth from "next-auth";
import { PrismaAdapter } from "@auth/prisma-adapter";
import { prisma } from "@/lib/db"; // Your Prisma client
import { authConfig } from "./auth.config";

export const {
  handlers,
  auth,
  signIn,
  signOut,
  update // Used to update the session manually
} = NextAuth({
  adapter: PrismaAdapter(prisma),
  session: { strategy: "jwt" }, // JWT is mandatory for Edge compatibility
  ...authConfig,
});

⚡ Quick Start: The 5-Minute Setup

Step 1: Install Dependencies

bun add next-auth@beta @auth/prisma-adapter

Step 2: Configure Environment Variables

# Generate with: npx auth secret
AUTH_SECRET=your_ultra_secure_secret_here

# Provider Credentials
AUTH_GITHUB_ID=...
AUTH_GITHUB_SECRET=...

Step 3: Create the Route Handler

app/api/auth/[...nextauth]/route.ts

import { handlers } from "@/auth";
export const { GET, POST } = handlers;

🌍 Universal Auth: The auth() Protocol

One of the most powerful features of v5 is the universal auth() function. It works everywhere.

1. In Server Components (RSC)

import { auth } from "@/auth";

export default async function ProfilePage() {
  const session = await auth();

  if (!session) {
    return <div>Not logged in.</div>;
  }

  return (
    <div>
      <h1>Welcome, {session.user?.name}</h1>
      <p>Role: {session.user?.role}</p>
    </div>
  );
}

2. In Server Actions

"use server"
import { auth } from "@/auth";

export async function createPost(content: string) {
  const session = await auth();
  if (!session) throw new Error("Unauthorized");

  // Securely access user data
  const authorId = session.user.id;
  // ... database logic
}

3. In Client Components

Use the useSession hook from next-auth/react. Note: You must wrap your app in <SessionProvider>.

"use client"
import { useSession } from "next-auth/react";

export function UserButton() {
  const { data: session, status } = useSession();

  if (status === "loading") return <div>...</div>;
  if (!session) return <button>Login</button>;

  return <img src={session.user.image} alt="Avatar" />;
}

🛡️ Route Protection & Middleware

The middleware.ts file is the first line of defense.

import NextAuth from "next-auth";
import { authConfig } from "./auth.config";

export default NextAuth(authConfig).auth;

export const config = {
  // Matcher allows excluding static files and api routes if needed
  matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
};

🧪 React 19 Server Actions & Authentication

React 19 introduces improved handling for forms and transitions. Use them for your login flows.

Login Action Example

"use server"
import { signIn } from "@/auth";
import { AuthError } from "next-auth";

export async function authenticate(
  prevState: string | undefined,
  formData: FormData,
) {
  try {
    await signIn("credentials", formData);
  } catch (error) {
    if (error instanceof AuthError) {
      switch (error.type) {
        case "CredentialsSignin":
          return "Invalid credentials.";
        default:
          return "Something went wrong.";
      }
    }
    throw error;
  }
}

🚫 The "Do Not" List (Common Pitfalls)

PitfallWhy it's badSolution
Using getServerSessionv4 legacy, slower in v5.Use auth().
NEXTAUTH_URLDeprecated in v5.Use AUTH_URL or let it auto-detect.
Prisma in MiddlewareMiddleware runs on Edge; Prisma needs Node.Use split config pattern.
Client-side only checksEasily bypassed by disabling JS.Always verify session on server.
Storing Secrets in ClientSecurity breach.Keep all secrets in .env.local.
Ignoring CSRFVulnerable to cross-site attacks.Use built-in handlers and Actions.

🏁 Security Hardening Checklist

  • Rotate Secrets: Ensure AUTH_SECRET is rotated periodically.
  • Secure Cookies: In production, cookies are automatically secure, but verify trustHost.
  • Role Validation: Don't just check !!session, check session.user.role === 'admin'.
  • Rate Limiting: Apply rate limiting to app/api/auth endpoints.
  • HTTPS Only: Ensure your site is served over HTTPS to protect session cookies.

🔧 Advanced Patterns: Types & Extensibility

Extending the session object is a common requirement.

next-auth.d.ts

import { type DefaultSession } from "next-auth";

export type ExtendedUser = DefaultSession["user"] & {
  role: "ADMIN" | "USER";
  id: string;
};

declare module "next-auth" {
  interface Session {
    user: ExtendedUser;
  }
}

Callback Logic for Roles

callbacks: {
  async session({ token, session }) {
    if (token.sub && session.user) {
      session.user.id = token.sub;
    }
    if (token.role && session.user) {
      session.user.role = token.role as "ADMIN" | "USER";
    }
    return session;
  },
  async jwt({ token }) {
    if (!token.sub) return token;

    const existingUser = await getUserById(token.sub);
    if (!existingUser) return token;

    token.role = existingUser.role;
    return token;
  }
}

📖 Deep Dives (References)

For more complex scenarios, consult the following specialized guides:


🛠️ Troubleshooting

"JWT expired" or "Invalid Signature"

Check if your AUTH_SECRET matches across all environments. If you changed it, all current sessions will be invalidated.

"Redirect recursion"

This usually happens when your middleware.ts logic redirects to /login but doesn't exclude /login from the middleware matcher or the authorized check.


🗄️ Advanced Database Integration: Custom Schemas

When using Prisma or Drizzle, you might need to customize the table names or add extra fields.

Prisma Schema Example

// schema.prisma
model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  role          UserRole  @default(USER)
  accounts      Account[]
  sessions      Session[]
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
}

enum UserRole {
  ADMIN
  USER
}

model Account {
  id                 String  @id @default(cuid())
  userId             String
  type               String
  provider           String
  providerAccountId  String
  refresh_token      String? @db.Text
  access_token       String? @db.Text
  expires_at         Int?
  token_type         String?
  scope              String?
  id_token           String? @db.Text
  session_state      String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

Drizzle Schema Example

import {
  timestamp,
  pgTable,
  text,
  primaryKey,
  integer,
} from "drizzle-orm/pg-core"
import type { AdapterAccount } from '@auth/core/adapters'

export const users = pgTable("user", {
  id: text("id").notNull().primaryKey(),
  name: text("name"),
  email: text("email").notNull(),
  emailVerified: timestamp("emailVerified", { mode: "date" }),
  image: text("image"),
})

export const accounts = pgTable(
  "account",
  {
    userId: text("userId")
      .notNull()
      .references(() => users.id, { onDelete: "cascade" }),
    type: text("type").$type<AdapterAccount["type"]>().notNull(),
    provider: text("provider").notNull(),
    providerAccountId: text("providerAccountId").notNull(),
    refresh_token: text("refresh_token"),
    access_token: text("access_token"),
    expires_at: integer("expires_at"),
    token_type: text("token_type"),
    scope: text("scope"),
    id_token: text("id_token"),
    session_state: text("session_state"),
  },
  (account) => ({
    compoundKey: primaryKey({ columns: [account.provider, account.providerAccountId] }),
  })
)

🌐 Internationalization (i18n) & Authentication

Handling redirects and error messages in multiple languages.

i18n-Aware Redirects

If you are using next-intl or a similar library, your auth logic should respect the current locale.

// auth.config.ts
callbacks: {
  authorized({ auth, request: { nextUrl } }) {
    const locale = nextUrl.pathname.split('/')[1] || 'en';
    const isLoggedIn = !!auth?.user;

    if (nextUrl.pathname.startsWith(`/${locale}/dashboard`) && !isLoggedIn) {
      return Response.redirect(new URL(`/${locale}/login`, nextUrl));
    }
    return true;
  }
}

🛡️ Multi-Factor Authentication (MFA) in 2026

While Auth.js doesn't have a "one-click" MFA, you can implement it using the callbacks and a custom session state.

Implementation Strategy

  1. First Factor: Standard login (OAuth/Credentials).
  2. MFA Check: After login, check if MFA is enabled for the user.
  3. Temporary Session: If MFA is required, mark the JWT as mfa_pending: true.
  4. Verification: Redirect to a /verify-mfa page.
  5. Finalize: Once verified, update the JWT to mfa_verified: true.
// Example JWT Callback for MFA
async jwt({ token, user }) {
  if (user) {
    token.mfa_required = user.hasMfa;
    token.mfa_verified = false;
  }
  return token;
}

// In Middleware
if (token?.mfa_required && !token?.mfa_verified && pathname !== "/verify-mfa") {
  return Response.redirect(new URL("/verify-mfa", nextUrl));
}

🧪 Testing Authentication

Testing auth flows is critical for preventing regressions.

1. Integration Testing with Vitest

Mock the auth function to test protected components.

import { vi, test, expect } from 'vitest';
import { auth } from '@/auth';

vi.mock('@/auth', () => ({
  auth: vi.fn(),
}));

test('shows secret content to logged-in users', async () => {
  (auth as any).mockResolvedValue({ user: { name: 'Test User' } });
  // Render component and assert
});

2. E2E Testing with Playwright

Use a dedicated test user and the storageState feature to stay logged in across tests.

import { test, expect } from '@playwright/test';

test('can access dashboard after login', async ({ page }) => {
  await page.goto('/login');
  await page.fill('input[name="email"]', 'test@example.com');
  await page.fill('input[name="password"]', 'password');
  await page.click('button[type="submit"]');

  await expect(page).toHaveURL('/dashboard');
});

🔗 External Resources


📜 Complete Implementation Example (The "Gold Standard")

auth.config.ts

import type { NextAuthConfig } from "next-auth";
import GitHub from "next-auth/providers/github";
import Credentials from "next-auth/providers/credentials";

export const authConfig = {
  providers: [
    GitHub,
    Credentials({
      async authorize(credentials) {
        // Validation logic here
        return null;
      }
    })
  ],
  callbacks: {
    authorized({ auth, request: { nextUrl } }) {
      // Logic here
      return true;
    }
  }
} satisfies NextAuthConfig;

auth.ts

import NextAuth from "next-auth";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { db } from "@/db";
import { authConfig } from "./auth.config";

export const { auth, handlers, signIn, signOut } = NextAuth({
  adapter: DrizzleAdapter(db),
  session: { strategy: "jwt" },
  ...authConfig,
});

middleware.ts

import NextAuth from "next-auth";
import { authConfig } from "./auth.config";

export default NextAuth(authConfig).auth;

export const config = {
  matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
};

*Updated: January 22, 2026 - 15:18*

平台分布

Codex

37.73%
按下载量换算42

Claude

32.5%
按下载量换算36

Cursor

17.05%
按下载量换算19

Gemini CLI

8.49%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

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

安装前确认

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

继续浏览同类 Skills