身份驗證後端管理流程
目的:使用私有後端用戶端對auth.inbox-manager.com進行身份驗證並執行特權使用者/帳戶/成員資格操作。
邊界註:
- 本指南針對
auth.inbox-manager.com和api.inbox-manager.com。 - 這些端點位於
api.inbox-manager.comOpenAPI 之外。
觀眾規則
- 此客戶端用於呼叫
api.inbox-manager.com/auth.inbox-manager.comAPI。 - 令牌受眾應為
https://api.inbox-manager.com。 - 公共應用程式用戶端與受眾
https://api.inbox-manager.com保持分離。
使用者介面流程
- 不使用瀏覽器。
- 後端服務透過客戶端憑證鑄造 M2M 令牌。
- 後端執行使用者/帳號/會員管理API。
- 後端在內部作業/日誌系統中記錄結果。
客戶端庫流程
const auth = new OAuthClient({
tokenUrl: "https://auth.inbox-manager.com/oauth2/token",
clientId: process.env.AUTH_BACKEND_ADMIN_CLIENT_ID!,
clientSecret: process.env.AUTH_BACKEND_ADMIN_CLIENT_SECRET!,
});
const token = await auth.clientCredentials({
audience: "https://api.inbox-manager.com",
});
const authApi = new InboxManagerAdminClient({
baseUrl: "https://api.inbox-manager.com",
bearerToken: token.access_token,
});
const user = await authApi.createApplicationUser(appId, { status: "active" });
const account = await authApi.createChildAccount(parentAccountId, {
name: "ops-provisioned",
});
const membership = await authApi.addAccountMember(
account.id,
user.id,
"viewer",
);
HTTP/curl 流程
curl -sS -X POST "https://auth.inbox-manager.com/oauth2/token" \
-H "content-type: application/json" \
--data "{
\"grant_type\": \"client_credentials\",
\"client_id\": \"${AUTH_BACKEND_ADMIN_CLIENT_ID}\",
\"client_secret\": \"${AUTH_BACKEND_ADMIN_CLIENT_SECRET}\",
\"audience\": \"https://api.inbox-manager.com\"
}"
然後調用:
-POST /api/applications/:application_id/users -POST /api/accounts/:account_id/accounts
POST /api/accounts/:account_id/members-PATCH /api/accounts/:account_id/members/:member_idDELETE /api/accounts/:account_id/members/:member_id-PATCH /api/accounts/:account_id-DELETE /api/accounts/:account_idDELETE /api/users/:user_id
驗證腳本
-scripts/auth_backend_admin_flow.sh