Token导航 LogoToken导航

Agent Skill · 研究检索

betterauth-fastapi-jwt-bridge(betterauth FastAPI JWT bridge 搜索)

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

betterauth-fastapi-jwt-bridge 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证为 MIT,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 47,601。

总安装 727周安装 30GitHub Stars 1下载 238核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/bilalmk/todo_correct --skill betterauth-fastapi-jwt-bridge

这个 Skill 是做什么的

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

实现 Better Auth(Next.js)与 FastAPI 之间的生产级 JWT 认证桥接方案。利用 JWKS 端点完成令牌验证,确保前后端认证一致性。支持用户登录后携带 Bearer Token 访问受保护 API 路由。

使用前应配置好 Better Auth 的 JWT 插件与 FastAPI 中间件验证逻辑。betterauth-fastapi-jwt-bridge 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/betterauth-fastapi-jwt-bridge

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

betterauth-fastapi-jwt-bridge 怎么安装?

在终端执行 npx skills add https://github.com/bilalmk/todo_correct --skill betterauth-fastapi-jwt-brid…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

betterauth-fastapi-jwt-bridge 支持哪些 AI 工具?

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

betterauth-fastapi-jwt-bridge 需要什么权限?

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

betterauth-fastapi-jwt-bridge 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

betterauth-fastapi-jwt-bridge 用的人多吗?

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

betterauth-fastapi-jwt-bridge 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 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调用外部服务未明确有提醒
betterauth-fastapi-jwt-bridge

betterauth FastAPI JWT bridge 搜索 · 本页

7271接触敏感数据MIT有提醒

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

SKILL.md 原文

Better Auth + FastAPI JWT Bridge

Implement production-ready JWT authentication between Better Auth (Next.js) and FastAPI using JWKS verification for secure, stateless authentication.

Architecture

User Login (Frontend)
    ↓
Better Auth → Issues JWT Token
    ↓
Frontend API Request → Authorization: Bearer <token>
    ↓
FastAPI Backend → Verifies JWT with JWKS → Returns filtered data

Quick Start Workflow

Step 1: Enable JWT in Better Auth (Frontend)

// lib/auth.ts
import { betterAuth } from "better-auth"
import { jwt } from "better-auth/plugins"

export const auth = betterAuth({
    plugins: [jwt()],  // Enables JWT + JWKS endpoint
    // ... other config
})

Database Migration Required:

After adding JWT plugin, run migrations to create required tables:

# Next.js (Better Auth CLI)
npx @better-auth/cli migrate

⚠️ IMPORTANT - Two Separate Tables Required:

  1. session table must have token column (core Better Auth requirement)

- Error: column "token" of relation "session" does not exist - Fix: See Database Schema Issues

  1. jwks table must exist (JWT plugin requirement)

- Error: relation "jwks" does not exist - Fix: See Database Schema Issues

These are separate migrations. The JWT plugin creates the jwks table but does NOT modify the session table.

Step 2: Verify JWKS Endpoint

Test the JWKS endpoint is working:

python scripts/verify_jwks.py http://localhost:3000/api/auth/jwks

Step 3: Implement Backend Verification

Copy templates from assets/ to your FastAPI project:

  • assets/jwt_verification.py → backend/app/auth/jwt_verification.py
  • assets/auth_dependencies.py → backend/app/auth/dependencies.py

Install dependencies:

pip install fastapi python-jose[cryptography] pyjwt cryptography httpx

Step 4: Protect API Routes

from app.auth.dependencies import verify_user_access

@router.get("/{user_id}/tasks")
async def get_tasks(
    user_id: str,
    user: dict = Depends(verify_user_access)
):
    # user_id is verified to match authenticated user
    return get_user_tasks(user_id)

Step 5: Configure Frontend API Client

Copy assets/api_client.ts to frontend/lib/api-client.ts and use:

import { getTasks, createTask } from "@/lib/api-client"

const tasks = await getTasks(userId)

⚠️ React Component Pattern:

Better Auth does NOT provide a useSession() hook. Use authClient.getSession() with useEffect:

import { useState, useEffect } from "react"
import { authClient } from "@/lib/auth-client"

function MyComponent() {
  const [user, setUser] = useState(null)

  useEffect(() => {
    async function loadSession() {
      const session = await authClient.getSession()
      if (session?.data?.user) {
        setUser(session.data.user)
      }
    }
    loadSession()
  }, [])

  return <div>Welcome {user?.name}</div>
}

See Frontend Integration Issues for complete examples.

Better Auth UUID Integration (Hybrid ID Architecture)

Problem Solved: Better Auth uses String IDs internally, but applications often need UUID for type consistency across API routes and database foreign keys.

Solution: Hybrid ID approach - User table has both id (String, Better Auth requirement) and uuid (UUID, application use).

Database Schema

CREATE TABLE "user" (
    id VARCHAR PRIMARY KEY,              -- Better Auth String ID
    uuid UUID UNIQUE NOT NULL,           -- Application UUID ⭐
    email VARCHAR UNIQUE NOT NULL,
    "emailVerified" BOOLEAN DEFAULT FALSE,
    name VARCHAR,
    "createdAt" TIMESTAMP NOT NULL,
    "updatedAt" TIMESTAMP NOT NULL
);

-- UUID auto-generated by database
ALTER TABLE "user" ALTER COLUMN uuid SET DEFAULT gen_random_uuid();

-- All foreign keys point to user.uuid
CREATE TABLE tasks (
    id UUID PRIMARY KEY,
    user_id UUID REFERENCES "user"(uuid) ON DELETE CASCADE,  -- ⭐ FK to uuid
    title VARCHAR NOT NULL,
    ...
);

Frontend Configuration (Better Auth)

Add UUID generation hook and JWT custom claim:

// lib/auth.ts
import { betterAuth } from "better-auth"
import { jwt } from "better-auth/plugins"
import { Pool } from "pg"

const pool = new Pool({ connectionString: process.env.DATABASE_URL })

export const auth = betterAuth({
  database: pool,

  // Hook to fetch database-generated UUID
  hooks: {
    user: {
      created: async ({ user }) => {
        const result = await pool.query(
          'SELECT uuid FROM "user" WHERE id = $1',
          [user.id]
        )
        const uuid = result.rows[0]?.uuid
        return { ...user, uuid }
      }
    }
  },

  // Include UUID in JWT payload
  plugins: [
    jwt({
      algorithm: "EdDSA",
      async jwt(user, session) {
        return {
          uuid: user.uuid,  // ⭐ Custom claim for backend
        }
      },
    }),
  ],
})

Backend Pattern (FastAPI)

Extract UUID from JWT custom claim (not sub):

# backend/app/auth/dependencies.py
from uuid import UUID

async def get_current_user(token: str = Depends(oauth2_scheme)) -> User:
    payload = verify_jwt_token(token)

    # Extract UUID from custom claim (not 'sub')
    user_uuid_str = payload.get("uuid")  # ⭐
    user_uuid = UUID(user_uuid_str)

    # Query by UUID
    user = await session.execute(
        select(User).where(User.uuid == user_uuid)
    )
    return user.scalar_one_or_none()

async def verify_user_match(
    user_id: UUID,  # From URL path
    current_user: User = Depends(get_current_user)
) -> User:
    # Compare UUIDs (not String IDs)
    if current_user.uuid != user_id:
        raise HTTPException(403, "Not authorized")
    return current_user

Key Pattern: Always query by User.uuid and validate against UUID from JWT custom claim.

Key Components

1. JWKS Verification Flow

  1. Fetch JWKS (cached) from Better Auth endpoint
  2. Extract kid (key ID) from JWT token header
  3. Find matching public key in JWKS by kid
  4. Verify signature using Ed25519 public key
  5. Validate claims (issuer, audience, expiration)
  6. Extract user info from payload (sub claim)

2. User Isolation Pattern

Always verify user_id from JWT matches user_id in URL:

if current_user["user_id"] != user_id:
    raise HTTPException(status_code=403, detail="Not authorized")

This prevents users from accessing other users' data.

3. JWT Payload Structure (Updated with UUID Integration)

{
  "sub": "user_abc123",       // Better Auth String ID
  "uuid": "a1b2c3d4-e5f6...", // Application UUID (custom claim) ⭐
  "email": "user@example.com",
  "name": "User Name",
  "iat": 1234567890,          // Issued at
  "exp": 1234567890,          // Expiration
  "iss": "http://localhost:3000",
  "aud": "http://localhost:3000"
}

Important: The uuid custom claim is used for backend user identification and database queries. Better Auth manages users with String IDs (sub), while the application uses UUIDs (uuid) for type consistency.

Environment Configuration

Frontend (.env.local):

BETTER_AUTH_SECRET="min-32-chars-secret"
BETTER_AUTH_URL="http://localhost:3000"
NEXT_PUBLIC_API_URL="http://localhost:8000"

Backend (.env):

BETTER_AUTH_URL="http://localhost:3000"
DATABASE_URL="postgresql://..."

Testing & Validation

Test JWKS Endpoint

python scripts/verify_jwks.py http://localhost:3000/api/auth/jwks

Expected output shows public keys with kid, kty, crv, and x fields.

Test JWT Verification

python scripts/test_jwt_verification.py \
  --jwks-url http://localhost:3000/api/auth/jwks \
  --token "eyJhbGci..."

Troubleshooting

Authentication Issues

IssueSolution
"relation 'jwks' does not exist"Create JWKS table migration - see Database Schema Issues
"column 'token' does not exist"Add token column to session table - see Database Schema Issues
"Token missing UUID (uuid claim)"Configure Better Auth hook and JWT plugin - see UUID Integration Issues
"User not found after registration"Dual auth system conflict - see UUID Integration Issues
"authClient.useSession is not a function"Use authClient.getSession() in useEffect - see Frontend Integration Issues
"No authentication token available"Use session.data.session.token not session.session.token - see Frontend Integration Issues
"Unable to find matching signing key"Clear JWKS cache in jwt_verification.py
"Token has expired"Frontend needs to refresh session
"Invalid token claims"Check issuer/audience match BETTER_AUTH_URL
403 Forbidden (UUID mismatch)Ensure UUID comparison, not String vs UUID - see UUID Integration Issues

Frontend-Backend Integration Issues (NEW - 2026-01-02)

IssueRoot CauseSolution
Tasks not displaying despite 200 OKBackend returns array, frontend expects paginated objectHandle both formats with Array.isArray() check - see Frontend-Backend Integration
Tag filtering crashesBackend returns tag objects {id, name, color}, frontend expected number[]Update TypeScript types to match Pydantic schemas - see Tag Filtering
Pagination shows "NaN"Optional priority field used in arithmetic without null checkAdd null checks with defaults for optional fields - see Priority Sorting
Tags not saving to databaseTaskCreate schema doesn't accept tags fieldUse multi-step operation: create task, then assign tags - see Tag Assignment
Edit form fields blankUncontrolled components + field name mismatches + datetime formatUse controlled components, match field names, convert datetime - see Edit Form
500 Error: timezone comparisonComparing offset-naive and offset-aware datetimesNormalize both to UTC before comparison - see Timezone Fix
Tag color validation failsFrontend required color, backend allows optionalMake color optional in Zod schema, provide defaults - see Tag Color
Tag filter checkboxes brokenBackend returns id: number, FilterContext uses string[]Convert IDs to strings for comparison - see Tag Filters

📚 Critical Reading: See Frontend-Backend Integration Issues section in troubleshooting guide for detailed fixes with code examples. This section documents 8 critical issues discovered during implementation and their resolutions.

Key Learnings:

  1. Always read backend Pydantic schemas before writing frontend types
  2. Handle optional fields with null checks and defaults
  3. Use controlled components for pre-filled forms
  4. Match field names exactly between frontend and backend
  5. Test with actual backend responses, not mocked data

See references/troubleshooting.md for detailed solutions and prevention strategies.

Advanced Topics

JWKS Caching Strategy

The implementation uses @lru_cache to cache JWKS responses:

  • Cache invalidated if token has unknown kid
  • Public keys rarely change (safe to cache)
  • Reduces network calls to Better Auth

See references/jwks-approach.md for implementation details.

Security Checklist

Before production:

  • ✅ HTTPS only for all API calls
  • ✅ Token expiration validated
  • ✅ Issuer/audience claims verified
  • ✅ User ID authorization enforced
  • ✅ CORS properly configured
  • ✅ Error messages don't leak sensitive info

See references/security-checklist.md for complete list.

Resources

scripts/

  • verify_jwks.py - Test JWKS endpoint availability
  • test_jwt_verification.py - Validate JWT token verification

references/

  • jwks-approach.md - Detailed JWKS implementation guide
  • security-checklist.md - Production security requirements
  • troubleshooting.md - Common issues and fixes

assets/

  • jwt_verification.py - Complete JWKS verification module template
  • auth_dependencies.py - FastAPI dependencies template
  • api_client.ts - Frontend API client template
  • better_auth_migrations.py - Alembic migration templates for Better Auth tables (including token column fix)

Why JWKS Over Shared Secret?

AspectJWKSShared Secret
Security✅ Asymmetric (more secure)⚠️ Symmetric (less secure)
Scalability✅ Multiple backends⚠️ Secret must be shared
Production✅ Recommended⚠️ Development only
ComplexityMediumSimple

Recommendation: Always use JWKS for production.

平台分布

Claude Code

28.88%
按下载量换算69

OpenCode

22.59%
按下载量换算54

Codex

20.19%
按下载量换算48

Antigravity

15.44%
按下载量换算37

Gemini CLI

7.77%
按下载量换算18

windsurf

3.72%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

接触敏感数据

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills