IM
TH
หน้าเอกสาร
เมนู
คู่มือ

ขั้นตอนผู้ดูแลระบบแบ็กเอนด์การตรวจสอบสิทธิ์

ใช้ไคลเอ็นต์แบ็กเอนด์ส่วนตัวเพื่อตรวจสอบสิทธิ์ `auth.inbox-manager.com` และเรียกใช้การดำเนินการผู้ใช้/บัญชี/สมาชิกที่ได้รับสิทธิพิเศษ

inbox-manager client-flow

ขั้นตอนผู้ดูแลระบบแบ็กเอนด์การรับรองความถูกต้อง

วัตถุประสงค์: ใช้ไคลเอ็นต์แบ็กเอนด์ส่วนตัวเพื่อตรวจสอบสิทธิ์ auth.inbox-manager.com และเรียกใช้การดำเนินการผู้ใช้/บัญชี/สมาชิกที่ได้รับสิทธิพิเศษ

หมายเหตุขอบเขต:

  • คู่มือนี้กำหนดเป้าหมายไปที่ auth.inbox-manager.com และ api.inbox-manager.com
  • จุดสิ้นสุดเหล่านี้อยู่นอก api.inbox-manager.com OpenAPI

กฎผู้ชม

  • ลูกค้ารายนี้มีไว้สำหรับการเรียก api.inbox-manager.com / auth.inbox-manager.com API
  • ผู้ชมโทเค็นควรเป็น https://api.inbox-manager.com
  • ไคลเอนต์แอปสาธารณะยังคงแยกจากผู้ชม https://api.inbox-manager.com

โฟลว์ UI

  1. ไม่มีการใช้เบราว์เซอร์
  2. บริการแบ็กเอนด์สร้างโทเค็น M2M ผ่านข้อมูลประจำตัวไคลเอ็นต์
  3. แบ็กเอนด์ดำเนินการ API ผู้ดูแลระบบผู้ใช้/บัญชี/สมาชิก
  4. Backend บันทึกผลลัพธ์ในระบบงาน/บันทึกภายใน

โฟลว์ไลบรารีไคลเอนต์

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 -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_id
  • DELETE /api/accounts/:account_id/members/:member_id
  • PATCH /api/accounts/:account_id
  • DELETE /api/accounts/:account_id
  • DELETE /api/users/:user_id

สคริปต์การตรวจสอบ

  • scripts/auth_backend_admin_flow.sh