跳到正文
Skillpedia
API 与服务器(后端)9.5k · #12258

convex-setup-auth

它能做什么

这个技能为 Convex 应用添加身份验证。它帮助你选择登录服务商,将其连接到你的用户,并限制某些功能只向已登录的人开放。

适用场景

  • ✓当你第一次为 Convex 应用添加登录功能时。
  • ✓当你需要一张用户表,将每个人与其登录身份关联起来时。
  • ✓当你希望某些函数或页面只限已登录用户或特定角色访问时。

技能链接

https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-setup-auth/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-setup-auth/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我的 Convex 应用设置登录,并确保只有已登录的用户才能看到自己的内容。”

每周 5 个新技能,1 分钟读完。

工作原理

除非你的项目已经在使用某个登录服务商,否则智能体会先询问你想使用哪一个。然后它会设置该服务商、用户表,以及用于检查当前登录者身份的辅助函数。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Convex Authentication Setup

Implement secure authentication in Convex with user management and access control.

When to Use

  • Setting up authentication for the first time
  • Implementing user management (users table, identity mapping)
  • Creating authentication helper functions
  • Setting up auth providers (Convex Auth, Clerk, WorkOS AuthKit, Auth0, custom JWT)

When Not to Use

  • Auth for a non-Convex backend
  • Pure OAuth/OIDC documentation without a Convex implementation
  • Debugging unrelated bugs that happen to surface near auth code
  • The auth provider is already fully configured and the user only needs a one-line fix

First Step: Choose the Auth Provider

Convex supports multiple authentication approaches. Do not assume a provider.

Before writing setup code:

  1. Ask the user which auth solution they want, unless the repository already makes it obvious
  2. If the repo already uses a provider, continue with that provider unless the user wants to switch
  3. If the user has not chosen a provider and the repo does not make it obvious, ask before proceeding

Common options:

  • Convex Auth - good default when the user wants auth handled directly in Convex
  • Clerk - use when the app already uses Clerk or the user wants Clerk's hosted auth features
  • WorkOS AuthKit - use when the app already uses WorkOS or the user wants AuthKit specifically
  • Auth0 - use when the app already uses Auth0
  • Custom JWT provider - use when integrating an existing auth system not covered above

Look for signals in the repo before asking:

  • Dependencies such as @clerk/*, @workos-inc/*, @auth0/*, or Convex Auth packages
  • Existing files such as convex/auth.config.ts, auth middleware, provider wrappers, or login components
  • Environment variables that clearly point at a provider

After Choosing a Provider

Read the provider's official guide and the matching local reference file:

The local reference files contain the concrete workflow, expected files and env vars, gotchas, and validation checks.

Use those sources for:

  • package installation
  • client provider wiring
  • environment variables
  • convex/auth.config.ts setup
  • login and logout UI patterns
  • framework-specific setup for React, Vite, or Next.js

For shared auth behavior, use the official Convex docs as the source of truth:

Prefer official docs over recalled steps, because provider CLIs and Convex Auth internals change between versions. Inventing setup from memory risks outdated patterns. For third-party providers, only add app-level user storage if the app actually needs user documents in Convex. Not every app needs a users table. For Convex Auth, follow the Convex Auth docs and built-in auth tables rather than adding a parallel users table plus storeUser flow, because Convex Auth already manages user records internally. After running provider initialization commands, verify generated files and complete the post-init wiring steps the provider reference calls out. Initialization commands rarely finish the entire integration.

Core Pattern: Protecting Backend Functions

The most common auth task is checking identity in Convex functions.

// Bad: trusting a client-provided userId
export const getMyProfile = query({
  args: { userId: v.id("users") },
  handler: async (ctx, args) => {
    return await ctx.db.get(args.userId);
  },
});
// Good: verifying identity server-side
export const getMyProfile = query({
  args: {},
  handler: async (ctx) => 
常见问题

它能设置哪些登录服务商?

根据你的选择,可以是 Convex Auth、Clerk、WorkOS AuthKit、Auth0 或自定义 JWT 设置。

它会替我选择服务商吗?

只有当你的项目已经在使用某个服务商时。否则,智能体会先询问你。

它也适用于其他后端吗?

不适用。它只适用于 Convex 应用。

详情

作者的原始描述

Sets up Convex auth, identity mapping, and access control. Use for login, auth providers, users tables, protected functions, or roles in a Convex app.

repo: openclaw/clawhub

热度

GitHub 星标
9.5k
排名
#12258
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能