Chuyển đến nội dung
Skillpedia
Bảo mật8.1k · #12595

webiny-configure-auth0

Skill này làm gì

Skill này hướng dẫn AI của bạn thiết lập Auth0 làm nhà cung cấp đăng nhập cho dự án Webiny. Skill dành cho lập trình viên muốn dùng Auth0 thay cho đăng nhập Cognito mặc định.

Khi nào nên dùng

  • ✓Khi bạn muốn Auth0 thay Cognito để đăng nhập vào dự án Webiny.
  • ✓Khi các claim JWT từ Auth0 cần ánh xạ sang dữ liệu danh tính Webiny.
  • ✓Khi bạn cần đặt biến môi trường issuer và client ID của Auth0.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/configure-auth0/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thay đăng nhập Cognito trong dự án Webiny của chúng tôi bằng Auth0 và lấy email người dùng từ token.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill giải thích cách cài gói Auth0, viết một lớp cấu hình để ánh xạ claim, và thêm thành phần extension Auth0 vào file cấu hình. Issuer và client ID được đặt làm biến môi trường trước khi triển khai.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

Cần những biến môi trường nào?

URL issuer và client ID, tên là AUTH0_ISSUER và AUTH0_CLIENT_ID.

Auth0 có thay thế Cognito hoàn toàn không?

Có. Skill mô tả Auth0 là sự thay thế cho xác thực Cognito mặc định.

Gói phải khớp với phiên bản nào?

Cùng phiên bản với dependency webiny trong package.json.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
8.1k
Vị trí xếp hạng
#12595
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự