auth
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAEM Config Service Authentication
AEM Config Service身份验证
This skill handles browser-based authentication for AEM Edge Delivery Services Config Service API using Playwright CLI. It opens a browser window for Adobe ID login and captures the auth token when the browser is closed.
此技能使用Playwright CLI处理AEM Edge Delivery Services Config Service API的基于浏览器的身份验证。它会打开浏览器窗口用于Adobe ID登录,并在浏览器关闭时捕获身份验证令牌。
When to Use This Skill
何时使用此技能
- Before generating admin/authoring/development guides that need API data
- When Config Service API returns 401 Unauthorized
- User says "login", "authenticate", "get auth token"
- Orchestrated by handover/admin/authoring/development skills
- 在生成需要API数据的管理员/创作/开发指南之前
- 当Config Service API返回401未授权时
- 用户提及"登录"、"身份验证"、"获取身份令牌"时
- 由移交/管理员/创作/开发技能编排调用
Prerequisites
前提条件
- Organization name must be known (from or user input)
.claude-plugin/project-config.json - Node.js and npm installed
- 必须知晓组织名称(来自或用户输入)
.claude-plugin/project-config.json - 已安装Node.js和npm
Authentication Flow
身份验证流程
Step 1: Get Organization and Site Names
步骤1:获取组织和站点名称
bash
undefinedbash
undefinedRead saved org name
Read saved org name
ORG=$(cat .claude-plugin/project-config.json 2>/dev/null | grep -o '"org"[[:space:]]:[[:space:]]"[^"]"' | sed 's/"org"[[:space:]]:[[:space:]]*"//' | sed 's/"$//')
If org is not saved, prompt user:
> "What is your Config Service organization name? (the `{org}` in `https://main--site--{org}.aem.page`)"
Save the org name:
```bash
mkdir -p .claude-pluginORG=$(cat .claude-plugin/project-config.json 2>/dev/null | grep -o '"org"[[:space:]]:[[:space:]]"[^"]"' | sed 's/"org"[[:space:]]:[[:space:]]*"//' | sed 's/"$//')
如果未保存组织名称,则提示用户:
> "您的Config Service组织名称是什么?(即`https://main--site--{org}.aem.page`中的`{org}`)"
保存组织名称:
```bash
mkdir -p .claude-pluginEnsure .claude-plugin is in .gitignore (contains auth tokens)
Ensure .claude-plugin is in .gitignore (contains auth tokens)
grep -qxF '.claude-plugin/' .gitignore 2>/dev/null || echo '.claude-plugin/' >> .gitignore
echo "{"org": "${ORG}"}" > .claude-plugin/project-config.json
Then fetch the first site name from Config Service (unauthenticated endpoint):
```bash
SITE=$(curl -s "https://admin.hlx.page/config/${ORG}/sites.json" | grep -o '"name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/"name"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')grep -qxF '.claude-plugin/' .gitignore 2>/dev/null || echo '.claude-plugin/' >> .gitignore
echo "{"org": "${ORG}"}" > .claude-plugin/project-config.json
然后从Config Service(未认证端点)获取第一个站点名称:
```bash
SITE=$(curl -s "https://admin.hlx.page/config/${ORG}/sites.json" | grep -o '"name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/"name"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')Step 2: Install Playwright (if needed)
步骤2:安装Playwright(如有需要)
bash
npx playwright --version 2>/dev/null || npm install -g playwright
npx playwright install chromium 2>/dev/null || truebash
npx playwright --version 2>/dev/null || npm install -g playwright
npx playwright install chromium 2>/dev/null || trueStep 3: Display Clear Instructions and Open Browser
步骤3:显示清晰说明并打开浏览器
IMPORTANT: Print highly visible instructions BEFORE opening the browser:
bash
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ BROWSER WINDOW OPENING FOR ADOBE ID LOGIN ║"
echo "║ ║"
echo "║ 1. Sign in with your Adobe ID credentials ║"
echo "║ 2. After successful login, CLOSE THE BROWSER WINDOW ║"
echo "║ ║"
echo "║ >>> CLOSE THE BROWSER TO CONTINUE <<< ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""Then open the browser with storage save:
bash
mkdir -p .claude-plugin
npx playwright open --save-storage=.claude-plugin/auth-storage.json "https://admin.hlx.page/login/${ORG}/${SITE}/main"Note: This command blocks until the browser is closed. The auth token is saved to when the browser closes.
auth-storage.json重要提示:在打开浏览器前,先显示高可见度的说明:
bash
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ BROWSER WINDOW OPENING FOR ADOBE ID LOGIN ║"
echo "║ ║"
echo "║ 1. Sign in with your Adobe ID credentials ║"
echo "║ 2. After successful login, CLOSE THE BROWSER WINDOW ║"
echo "║ ║"
echo "║ >>> CLOSE THE BROWSER TO CONTINUE <<< ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""然后打开浏览器并保存存储:
bash
mkdir -p .claude-plugin
npx playwright open --save-storage=.claude-plugin/auth-storage.json "https://admin.hlx.page/login/${ORG}/${SITE}/main"注意: 此命令会阻塞直到浏览器关闭。当浏览器关闭时,身份令牌会保存到中。
auth-storage.jsonStep 4: Extract Auth Token from Storage
步骤4:从存储中提取身份令牌
After browser is closed, extract the token:
bash
echo ""
echo "Browser closed. Extracting auth token..."
AUTH_TOKEN=$(node -e "
const fs = require('fs');
try {
const data = JSON.parse(fs.readFileSync('.claude-plugin/auth-storage.json', 'utf8'));
const cookie = data.cookies.find(c => c.name === 'auth_token');
if (cookie) {
console.log(cookie.value);
} else {
console.error('ERROR: auth_token cookie not found. Login may have failed.');
process.exit(1);
}
} catch (e) {
console.error('ERROR: Could not read auth storage file.');
process.exit(1);
}
")浏览器关闭后,提取令牌:
bash
echo ""
echo "Browser closed. Extracting auth token..."
AUTH_TOKEN=$(node -e "
const fs = require('fs');
try {
const data = JSON.parse(fs.readFileSync('.claude-plugin/auth-storage.json', 'utf8'));
const cookie = data.cookies.find(c => c.name === 'auth_token');
if (cookie) {
console.log(cookie.value);
} else {
console.error('ERROR: auth_token cookie not found. Login may have failed.');
process.exit(1);
}
} catch (e) {
console.error('ERROR: Could not read auth storage file.');
process.exit(1);
}
")Step 5: Save Auth Token to Project Config
步骤5:将身份令牌保存到项目配置中
bash
ORG=$(cat .claude-plugin/project-config.json | grep -o '"org"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"org"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
echo "{\"org\": \"${ORG}\", \"authToken\": \"${AUTH_TOKEN}\"}" > .claude-plugin/project-config.jsonbash
ORG=$(cat .claude-plugin/project-config.json | grep -o '"org"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"org"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
echo "{\"org\": \"${ORG}\", \"authToken\": \"${AUTH_TOKEN}\"}" > .claude-plugin/project-config.jsonClean up storage file (contains sensitive session data)
Clean up storage file (contains sensitive session data)
rm -f .claude-plugin/auth-storage.json
echo "Auth token saved successfully."
undefinedrm -f .claude-plugin/auth-storage.json
echo "Auth token saved successfully."
undefinedStep 6: Verify Token Works
步骤6:验证令牌是否有效
bash
AUTH_TOKEN=$(cat .claude-plugin/project-config.json | grep -o '"authToken"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"authToken"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
ORG=$(cat .claude-plugin/project-config.json | grep -o '"org"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"org"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
HTTP_CODE=$(curl -s -w "%{http_code}" -o /dev/null -H "x-auth-token: ${AUTH_TOKEN}" \
"https://admin.hlx.page/config/${ORG}/sites.json")
if [ "$HTTP_CODE" = "200" ]; then
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ✓ AUTHENTICATION SUCCESSFUL ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
else
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ✗ AUTHENTICATION FAILED (HTTP $HTTP_CODE) ║"
echo "║ Please try again ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
fibash
AUTH_TOKEN=$(cat .claude-plugin/project-config.json | grep -o '"authToken"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"authToken"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
ORG=$(cat .claude-plugin/project-config.json | grep -o '"org"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"org"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
HTTP_CODE=$(curl -s -w "%{http_code}" -o /dev/null -H "x-auth-token: ${AUTH_TOKEN}" \
"https://admin.hlx.page/config/${ORG}/sites.json")
if [ "$HTTP_CODE" = "200" ]; then
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ✓ AUTHENTICATION SUCCESSFUL ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
else
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ✗ AUTHENTICATION FAILED (HTTP $HTTP_CODE) ║"
echo "║ Please try again ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""
fiToken Storage
令牌存储
Auth tokens are stored in :
.claude-plugin/project-config.jsonjson
{
"org": "myorg",
"authToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}Security Note: Add to .
.claude-plugin/.gitignore身份令牌存储在中:
.claude-plugin/project-config.jsonjson
{
"org": "myorg",
"authToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}安全注意事项: 将添加到中。
.claude-plugin/.gitignoreUsing the Token in Other Skills
在其他技能中使用令牌
bash
AUTH_TOKEN=$(cat .claude-plugin/project-config.json 2>/dev/null | grep -o '"authToken"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"authToken"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
curl -H "x-auth-token: ${AUTH_TOKEN}" \
"https://admin.hlx.page/config/${ORG}/sites/{site}/access.json"bash
AUTH_TOKEN=$(cat .claude-plugin/project-config.json 2>/dev/null | grep -o '"authToken"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"authToken"[[:space:]]*:[[:space:]]*"//' | sed 's/"$//')
curl -H "x-auth-token: ${AUTH_TOKEN}" \
"https://admin.hlx.page/config/${ORG}/sites/{site}/access.json"Troubleshooting
故障排除
| Issue | Solution |
|---|---|
| Run |
| Browser doesn't open | Run |
| Token not found after login | Ensure login completed before closing browser |
| Login page not loading | Verify org/site names are correct |
| API returns 401 | Token expired, re-authenticate |
| 问题 | 解决方案 |
|---|---|
| 运行 |
| 浏览器无法打开 | 运行 |
| 登录后未找到令牌 | 确保完成登录后再关闭浏览器 |
| 登录页面无法加载 | 验证组织/站点名称是否正确 |
| API返回401 | 令牌已过期,请重新进行身份验证 |
Integration with Other Skills
与其他技能的集成
Called by: , , ,
adminauthoringdevelopmenthandoverInvocation:
Skill({ skill: "project-management:auth" })调用者:、、、
adminauthoringdevelopmenthandover调用方式:
Skill({ skill: "project-management:auth" })