跳到正文
Skillpedia
安全8.1k · #12595

webiny-configure-auth0

它能做什么

这个技能指导你的 AI 为 Webiny 项目设置 Auth0 作为登录服务商。适用于希望用 Auth0 取代默认 Cognito 登录的开发者。

适用场景

  • ✓希望用 Auth0 取代 Cognito 登录 Webiny 项目的时候。
  • ✓需要将 Auth0 的 JWT 声明映射到 Webiny 身份数据的时候。
  • ✓需要设置 Auth0 issuer 和客户端 ID 环境变量的时候。

技能链接

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/configure-auth0/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“请帮我把 Webiny 项目中的 Cognito 登录替换为 Auth0,并从令牌中映射用户邮箱。”

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

工作原理

该技能讲解了安装 Auth0 包、编写映射声明的配置类,并在配置文件中添加 Auth0 扩展组件。部署前需要将 issuer 和客户端 ID 设置为环境变量。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Configure Auth0 Authentication

TL;DR

Webiny supports Auth0 as an external identity provider (IDP) to replace the default Cognito authentication. First, install the @webiny/auth0 package (using the same version as the webiny dependency in package.json). Then create two files: an API config class that maps Auth0 JWT claims to Webiny identity data (Auth0IdpConfig), and a React extension component (<Auth0 />) that wires issuer URL, client ID, and the API config path. Register the extension in webiny.config.tsx, set two environment variables (AUTH0_ISSUER, AUTH0_CLIENT_ID), and deploy.

Pattern / Core Concept

Auth0 integration has two parts:

  1. API Config — A class implementing Auth0IdpConfig.Interface that maps JWT token claims to Webiny's identity structure. Registered via Auth0IdpConfig.createImplementation() (the universal DI pattern).
  2. Extension Component — A React component that renders <Auth0 /> from @webiny/auth0, passing the issuer URL, client ID, and path to the API config file. The <Auth0 /> component handles environment variable injection, API extension registration, and Admin login screen setup automatically.

How <Auth0 /> Works Internally

The <Auth0 /> component (from @webiny/auth0) is a defineExtension that:

  • Sets Lambda env vars: AUTH0_ISSUER, AUTH0_CLIENT_ID
  • Sets Admin app env vars: REACT_APP_IDP_TYPE=auth0, REACT_APP_AUTH0_ISSUER, REACT_APP_AUTH0_CLIENT_ID
  • Registers the internal Auth0IdpFeature API extension (OIDC token verification)
  • Registers your custom API config extension (identity mapping)
  • Registers the Admin Auth0 login screen extension

Reference Tables

Auth0IdpConfig.Interface

Method Signature Required Description
getIdentity (token: JwtPayload) => Auth0Identity | Promise<Auth0Identity> Yes Maps JWT claims to Webiny identity data
verifyTokenClaims (token: JwtPayload) => void | Promise<void> No Custom claim verification (throw to reject the token)

Auth0Identity (Return Type of getIdentity)

Field Type Description
id string Unique user ID (typically token["sub"])
displayName string User's display name
roles string[] Webiny security roles to assign
teams string[] Webiny teams (optional, filter out falsy values)
profile { firstName, lastName, email } User profile fields
context object Runtime data (not stored in DB)

<Auth0 /> Component Props

Prop Type Description
issuer string Auth0 issuer URL (e.g., https://your-tenant.auth0.com)
clientId string Auth0 application client ID
apiConfig string Absolute path to the API config file

Environment Variables

Variable Used By Description
AUTH0_ISSUER API + Admin Auth0 issuer URL
AUTH0_CLIENT_ID API + Admin Auth0 application client ID

Full Examples

Example 1: Basic Auth0 Configuration

Step 0: Install the @webiny/auth0 dependency

@webiny/auth0 is an optional dependency. Add it to package.json using the same version as the webiny dependency, then install:

# Check the webiny version in package.json, then add @webiny/auth0 with the same version
# For example, if "webiny": "^0.0.0-unstable.xxx":
yarn add @webiny/auth0@^0.0.0-unstable.xxx

Important: After adding the dependency, tell the user to r

常见问题

需要哪些环境变量?

issuer 网址和客户端 ID,分别命名为 AUTH0_ISSUER 和 AUTH0_CLIENT_ID。

Auth0 会完全替换 Cognito 吗?

是的。该技能将 Auth0 描述为默认 Cognito 身份验证的替代方案。

包的版本必须与什么匹配?

必须与 package.json 中 webiny 依赖的版本一致。

详情

作者的原始描述

Configuring Auth0 as an identity provider (IDP) for Webiny projects. Use this skill when the developer asks about Auth0 authentication, Auth0 SSO, replacing Cognito with Auth0, setting up external identity providers, configuring OIDC authentication, mapping JWT claims to Webiny identities, or customizing the Auth0 login flow. Also relevant when asking about AUTH0_ISSUER, AUTH0_CLIENT_ID environment variables, Auth0IdpConfig, or the MyAuth0Extension pattern.

repo: webiny/webiny-js

热度

GitHub 星标
8.1k
排名
#12595
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能