auth-nodejs-cloudbase skill
✓ 인증됨Node.js 백엔드 서비스에서 서버 측 ID 관리, 사용자 프로필 조회 및 커스텀 로그인 티켓 발급을 가능하게 합니다.
- GitHub 스타
- 1,164
- 파일
- 2
- 마지막 커밋
- 2026년 11월 11일
- 라이선스
- MIT
- 허용된 도구
- —
auth-nodejs-cloudbase skill은 무엇을 하나요?
Node.js 백엔드 서비스에서 서버 측 ID 관리, 사용자 프로필 조회 및 커스텀 로그인 티켓 발급을 가능하게 합니다.
skill의 SKILL.md에서 생성된 요약입니다.
auth-nodejs-cloudbase skill 정보
이 SKILL은 Node.js 백엔드 서비스 내에서 서버 측 ID와 사용자 프로필을 관리할 수 있도록 지원합니다. CloudBase 클라우드 함수나 요청자의 신원을 확인하거나 최종 사용자 데이터를 검사해야 하는 장기 실행 Node.js 서비스를 개발하는 개발자를 위해 설계되었습니다. 에이전트는 @cloudbase/node-sdk를 사용하여 호출자 ID를 읽고, UID 또는 로그인 식별자를 통해 특정 사용자 프로필을 조회하며, 기존 외부 사용자 시스템을 CloudBase 환경으로 연결하는 로직을 구현할 수 있습니다.
에이전트가 이 SKILL을 로드하면 현재 호출자를 식별하는 getUserInfo, 상세 프로필을 가져오는 getEndUserInfo, 이메일 또는 전화번호로 사용자를 찾는 queryUserInfo와 같은 특정 도구에 접근할 수 있습니다. 또한 createTicket을 통해 커스텀 로그인 티켓을 발급할 수 있어, 백엔드에서 외부 시스템의 사용자를 인증할 수 있습니다. 이 SKILL은 백엔드 ID 로직에만 집중하며, 인증 제공자 설정, 프론트엔드 로그인 인터페이스 관리 또는 로우 레벨 HTTP API 통합에는 사용하지 않습니다.
agent가 수행할 수 있는 작업
- 1현재 함수 호출자 식별권한 부여 결정을 내리기 위해 현재 클라우드 함수를 호출 중인 사용자의 고유 식별자를 가져옵니다.
- 2상세 사용자 프로필 조회데이터베이스를 통해 특정 사용자의 고유 ID를 알고 있는 경우, 해당 사용자의 포괄적인 프로필 정보를 가져옵니다.
- 3외부 사용자 시스템 연결클라이언트가 기존의 제3자 사용자 데이터베이스를 사용하여 인증할 수 있도록 커스텀 로그인 티켓을 생성합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
auth-nodejs-cloudbase skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.Claude Code에 auth-nodejs-cloudbase skill 설치
~/.claude/skills/auth-nodejs-cloudbase/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase ~/.claude/skills/auth-nodejs-cloudbaseClaude Code (project)에 auth-nodejs-cloudbase skill 설치
.claude/skills/auth-nodejs-cloudbase/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase .claude/skills/auth-nodejs-cloudbaseCodex에 auth-nodejs-cloudbase skill 설치
~/.agents/skills/auth-nodejs-cloudbase/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase ~/.agents/skills/auth-nodejs-cloudbaseGemini CLI에 auth-nodejs-cloudbase skill 설치
~/.gemini/skills/auth-nodejs-cloudbase/SKILL.md
$ npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase ~/.gemini/skills/auth-nodejs-cloudbaseClaude.ai에 auth-nodejs-cloudbase skill 설치
npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase auth-nodejs-cloudbase && zip -r auth-nodejs-cloudbase.zip auth-nodejs-cloudbase # claude.ai → Customize → Skills → + → Create skill → Upload a skill → auth-nodejs-cloudbase.zip
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 보안 감사는 아닙니다. 에이전트가 실행하기 전에 스크립트를 읽어 보세요. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능tencentcloudbase/cloudbase-ai-toolkit/config/.claude/skills/auth-nodejs-cloudbase is public and reachablegithub.com/tencentcloudbase/cloudbase-ai-toolkit/tree/HEAD/c ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-11github.com/tencentcloudbase/cloudbase-ai-toolkit/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음No scripts in the skill folder통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗통과
- 사전 허용 도구가 제한됨No pre-approved tools; the agent asks before using onegithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗통과
- SKILL.md가 Agent Skills 형식을 따름the description does not say when to use the skillgithub.com/tencentcloudbase/cloudbase-ai-toolkit/blob/HEAD/c ↗결함 발견
SKILL.md
GitHub에서 보기Sibling skills (local only)
Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.
If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.
Activation Contract
Use this first when
- Node.js code in cloud functions or backend services must read caller identity, look up users, or issue custom login tickets.
- The backend responsibility is auth / identity, not provider setup or frontend login UI.
Read before writing code if
- The task mentions
@cloudbase/node-sdk, server-side auth, custom login tickets, or "who is calling". - The request mixes frontend login with backend identity logic; split the flow and route client-side work elsewhere.
Then also read
- Provider setup / publishable key ->
../auth-tool-cloudbase/SKILL.md - Web login UI that consumes custom tickets ->
../auth-web-cloudbase/SKILL.md - Raw HTTP auth client ->
../http-api-cloudbase/SKILL.md
Do NOT use for
- Provider enable/disable or login console configuration.
- Frontend login / sign-up UI.
- Mini program native auth.
Common mistakes / gotchas
- Using this skill as the entry point for every auth request.
- Mixing provider-management work with Node-side identity code.
- Reaching for raw HTTP examples when Node SDK already covers the job.
When to use this skill
Use this skill whenever the task involves server-side authentication or identity in a CloudBase project, and the code is running in Node.js, for example:
- CloudBase 云函数 (Node runtime) that needs to know who is calling
- Node services that use CloudBase Node SDK to look up user information
- Backends that issue custom login tickets for Web / mobile clients
- Admin or ops tools that need to inspect CloudBase end-user profiles
Do NOT use this skill for:
- Frontend Web login / sign-up flows using
@cloudbase/js-sdk(handle those with the auth-web skill, not this Node skill). - Direct HTTP auth API integrations (this skill does not describe raw HTTP endpoints; use the http-api skill instead).
- Database or storage operations that do not involve identity (use database/storage docs or skills).
When the user request mixes frontend and backend concerns (e.g. "build a web login page and a Node API that knows the user"), treat them separately:
- Use Web-side auth docs/skills for client login and UX.
- Use this Node Auth skill for how the backend sees and uses the authenticated user.
How to use this skill (for a coding agent)
When you load this skill to work on a task:
-
Clarify the runtime and responsibility
Ask the user:
- Where does this Node code run?
- CloudBase 云函数
- Long‑running Node service using CloudBase
- What do they need from auth?
- Just the caller identity for authorization?
- Look up arbitrary users by UID / login identifier?
- Bridge their own user system into CloudBase via custom login?
- Where does this Node code run?
-
Confirm CloudBase environment and SDK
- Ask for:
env– CloudBase environment ID
- Install the latest
@cloudbase/node-sdkfrom npm if it is not already available. - Always initialize the SDK using this pattern (values can change, shape must not):
import tcb from "@cloudbase/node-sdk"; const app = tcb.init({ env: "your-env-id" }); const auth = app.auth(); - Ask for:
-
Pick the relevant scenario from this file
- For caller identity inside a function, use the
getUserInfoscenarios. - For full user profile or admin lookup, use the
getEndUserInfoandqueryUserInfoscenarios. - For client systems that already have their own users, use the custom login ticket scenarios built on
createTicket. - For logging / security, use the
getClientIPscenario.
- For caller identity inside a function, use the
-
Follow Node SDK API shapes exactly
- Treat all
auth.*methods and parameter shapes in this file as canonical. - You may change variable names and framework (e.g. Express vs 云函数 handler), but do not change SDK method names or parameter fields.
- If you see a method in older code that is not listed here or in the Node SDK docs mirror, treat it as suspect and avoid using it.
- Treat all
-
If you are unsure about an API
- Consult the official CloudBase Auth Node SDK documentation.
- Only use methods and shapes that appear in the official documentation.
- If you cannot find an API you want:
- Prefer composing flows from the documented methods, or
- Explain that this skill only covers Node SDK auth, and suggest using the relevant CloudBase Web or HTTP auth documentation for client-side or raw-HTTP flows.
Node auth architecture – how Node fits into CloudBase Auth
CloudBase Auth separates where users log in from where backend code runs:
- Users log in through the supported auth methods (username/password, SMS, email, WeChat, custom login, anonymous — disabled by default, etc.) using client SDKs or HTTP interfaces, as described in the official CloudBase Auth overview documentation.
- Once logged in, CloudBase attaches the user identity and tokens to the environment.
- Node code then reads that identity using the Node SDK, or bridges external identities into CloudBase using custom login.
In practice, Node code usually does one or more of:
-
Identify the current caller
- In 云函数, use
auth.getUserInfo()to readuid,openId, andcustomUserId. - Use this identity for authorization decisions, logging, and personalisation.
- In 云函数, use
-
Look up other users
- Use
auth.getEndUserInfo(uid)when you know the CloudBaseuid. - Use
auth.queryUserInfo({ platform, platformId, uid? })when you only have login identifiers such as phone, email, username, or a custom ID.
- Use
-
Issue custom login tickets
- When you already have your own user system, your Node backend can call
auth.createTicket(customUserId, options)and return the ticket to a trusted client. - The client (typically Web) then uses this ticket with the Web SDK to log the user into CloudBase without forcing them to sign up again.
- When you already have your own user system, your Node backend can call
-
Log client IP for security
- In 云函数,
auth.getClientIP()returns the caller IP, which you can use for audit logs, anomaly detection, or access control.
- In 云函数,
The scenarios later in this file turn these responsibilities into explicit, copy‑pasteable patterns.
Node Auth APIs covered by this skill
This skill covers the following auth methods on the CloudBase Node SDK. Treat these method signatures as the only supported entry points for Node auth flows when using this skill:
-
getUserInfo(): IGetUserInfoResultReturns{ openId, appId, uid, customUserId }for the current caller. -
getEndUserInfo(uid?: string, opts?: ICustomReqOpts): Promise<{ userInfo: EndUserInfo; requestId?: string }>Returns detailed CloudBase end‑user profile for a givenuidor for the current caller (whenuidis omitted). -
queryUserInfo(query: IUserInfoQuery, opts?: ICustomReqOpts): Promise<{ userInfo: EndUserInfo; requestId?: string }>Finds a user by login identifier (platform+platformId) oruid. -
getClientIP(): stringReturns the caller’s IP address when running in a supported environment (e.g. 云函数). -
createTicket(customUserId: string, options?: ICreateTicketOpts): stringCreates a custom login ticket for the givencustomUserIdthat clients can exchange for a CloudBase login.
The exact field names and allowed values for EndUserInfo, IUserInfoQuery, and ICreateTicketOpts are defined by the official CloudBase Node SDK typings and documentation. When writing Node code, do not guess shapes; follow the SDK types and the examples in this file.
Scenarios – Node auth patterns
Scenario 1: Initialize Node SDK and auth in a CloudBase function
Use this when writing a CloudBase 云函数 that needs to interact with Auth:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
// Your logic here
};
Key points:
- Use the same
envas configured for the function’s CloudBase 环境. - Avoid hardcoding sensitive values; prefer environment variables or function configuration.
Scenario 2: Get caller identity in a CloudBase function
Use this when you need to know who is calling your cloud function:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const { openId, appId, uid, customUserId } = auth.getUserInfo();
console.log("Caller identity", { openId, appId, uid, customUserId });
// Use uid / customUserId for authorization decisions
// e.g. check roles, permissions, or data ownership
};
Best practices:
- Treat
uidas the canonical CloudBase user identifier. - Use
customUserIdonly when you have enabled 自定义登录 and mapped your own users. - Never trust
openId/appIdalone for authorization; they are WeChat‑specific identifiers.
Scenario 3: Get full end‑user profile by UID
Use this when you know a user’s CloudBase uid (for example, from a database record) and you need detailed profile information:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const uid = "user-uid";
try {
const { userInfo } = await auth.getEndUserInfo(uid);
console.log("User profile", userInfo);
} catch (error) {
console.error("Failed to get end user info", error.message);
}
};
Best practices:
- Call
getEndUserInfofrom trusted backend code only; do not expose it directly to untrusted clients. - Log minimal necessary data for debugging; avoid logging full profiles in production.
Scenario 4: Get full profile for the current caller
Use this when you want the current caller’s full profile without manually passing uid:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
try {
const { userInfo } = await auth.getEndUserInfo();
console.log("Current caller profile", userInfo);
} catch (error) {
console.error("Failed to get current caller profile", error.message);
}
};
This relies on the environment providing the caller’s identity (e.g. within a CloudBase 云函数). If called where no caller context exists, refer to the official docs and handle errors gracefully.
Scenario 5: Query user by login identifier
Use this when you only know a user’s login identifier (phone, email, username, or custom ID) and need their CloudBase profile:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
try {
// Find by phone number
const { userInfo: byPhone } = await auth.queryUserInfo({
platform: "PHONE",
platformId: "+86 13800000000",
});
// Find by email
const { userInfo: byEmail } = await auth.queryUserInfo({
platform: "EMAIL",
platformId: "test@example.com",
});
// Find by customUserId
const { userInfo: byCustomId } = await auth.queryUserInfo({
platform: "CUSTOM",
platformId: "your-customUserId",
});
console.log({ byPhone, byEmail, byCustomId });
} catch (error) {
console.error("Failed to query user info", error.message);
}
};
Best practices:
- Prefer
uidwhen you already have it; usequeryUserInfoonly when needed. - Make sure
platformIduses the exact format you used at sign‑up (e.g.+86+ phone number).
Scenario 6: Get client IP in a function
Use this for logging or basic IP‑based checks:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({ env: "your-env-id" });
const auth = app.auth();
exports.main = async (event, context) => {
const ip = auth.getClientIP();
console.log("Caller IP", ip);
// e.g. block or flag suspicious IPs
};
Custom login tickets (Node side only)
Custom login lets you keep your existing user system while still mapping each user to a CloudBase account.
Scenario 7: Initialize Node SDK with custom login credentials
Before issuing tickets, install the custom login private key file from the CloudBase console and load it in Node:
import tcb from "@cloudbase/node-sdk";
import path from "node:path";
const app = tcb.init({
env: "your-env-id",
credentials: require(path.join(__dirname, "tcb_custom_login.json")),
});
const auth = app.auth();
Keep tcb_custom_login.json secret and never bundle it into frontend code.
Scenario 8: Issue a custom login ticket for a given customUserId
Use this in backend code that has already authenticated your own user and wants to let them log into CloudBase:
import tcb from "@cloudbase/node-sdk";
const app = tcb.init({
env: "your-env-id",
credentials: require("/secure/path/to/tcb_custom_login.json"),
});
const auth = app.auth();
exports.main = async (event, context) => {
const customUserId = "your-customUserId";
const ticket = auth.createTicket(customUserId, {
refresh: 3600 * 1000, // access_token refresh interval (ms)
expire: 24 * 3600 * 1000, // ticket expiration time (ms)
});
// Return the ticket to the trusted client (e.g. via HTTP response)
return { ticket };
};
Constraints for customUserId (from official docs):
- Length 4–32 characters.
- Allowed characters: letters, digits, and
_-#@(){}[]:.,<>+#~.
Best practices:
- Only issue tickets after your own user authentication succeeds.
- Store
customUserIdin your own user database and keep it stable over time. - Do not reuse
customUserIdfor multiple distinct people.
Scenario 9: How this pairs with Web custom login
This skill only covers Node-side ticket issuance. For the client-side flow:
- On the client (Web), use
@cloudbase/js-sdk's custom login support:- Call your backend endpoint that returns
ticket. - Configure
auth.setCustomSignFunc(async () => ticketFromBackend). - Call
auth.signInWithCustomTicket()to finish login.
- Call your backend endpoint that returns
Keep the responsibility clear:
- Node: authenticate your own user → create ticket → return ticket securely.
- Web: receive ticket → sign into CloudBase using documented Web SDK APIs.
Node auth best practices
-
Single source of truth for identity
- Treat CloudBase
uidas the primary key when relating end‑user records. - Use
customUserIdonly as a bridge to your own user system.
- Treat CloudBase
-
Least privilege
- Perform authorization checks in Node using
uid, roles, and ownership, not just login success. - Avoid exposing raw
getEndUserInfo/queryUserInforesults directly to clients.
- Perform authorization checks in Node using
-
Error handling
- Wrap all
auth.*calls intry/catchwhen they return promises. - Log
error.message(anderror.codeif present), but avoid logging sensitive data.
- Wrap all
-
Security
- Protect
tcb_custom_login.jsonas you would any private key. - Rotate custom login keys according to CloudBase guidance when necessary.
- Use HTTPS and proper authentication between your clients and Node backend when exchanging tickets.
- Protect
Summary
Use this Node Auth skill whenever you need to:
- Know who is calling your Node code in CloudBase.
- Look up CloudBase users by
uidor login identifier. - Bridge an existing user system into CloudBase with custom login tickets.
- Apply consistent, secure, server‑side auth best practices.
For end‑to‑end experiences, pair this skill with:
- Web‑side auth documentation (for all browser‑side login and UX using
@cloudbase/js-sdk). - CloudBase HTTP auth documentation (for language‑agnostic HTTP integrations, if you are using those).
Treat the official CloudBase Auth Node SDK documentation as the canonical reference for Node auth APIs, and treat the scenarios in this file as vetted best‑practice building blocks.
이 스킬의 파일
2auth-nodejs-cloudbase skill 질문
Claude Code에 auth-nodejs-cloudbase skill을 어떻게 설치하나요?
npx degit TencentCloudBase/CloudBase-AI-Toolkit/config/.claude/skills/auth-nodejs-cloudbase ~/.claude/skills/auth-nodejs-cloudbase를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
auth-nodejs-cloudbase skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
이 SKILL은 언제 사용해야 하나요?
클라우드 함수나 백엔드 서비스의 Node.js 코드에서 호출자 ID를 읽거나, 사용자를 조회하거나, 커스텀 로그인 티켓을 발급해야 할 때 사용합니다.