身份验证后端管理流程
目的:使用私有后端客户端对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