OAuth2 & OpenID Connect Deep Dive · บทเรียน

คำขอ Claims และ Claims แบบรวม

เรียนรู้วิธีที่ OpenID Connect ให้ไคลเอนต์ขอ Claims เฉพาะรายการด้วยพารามิเตอร์ claims และวิธีที่ Claims แบบกระจายและแบบรวมส่งคำยืนยันจากแหล่งข้อมูลภายนอก

บทเรียน 4 จาก 413 ขั้นตอน

คำขอ Claims และ Claims แบบรวม เป็นบทเรียน OAuth2 & OpenID Connect Deep Dive ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน OAuth2 & OpenID Connect Deep Dive และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส OAuth2 & OpenID Connect Deep Dive มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Requesting Specific Claims

Beyond scopes like profile or email, OIDC offers a finer-grained claims request parameter. It lets a client ask for individual claims and target where they appear: in the ID token or from UserInfo.

The claims Parameter Shape

The claims parameter is a JSON object with two top-level members: id_token and userinfo. Each maps claim names to a value describing how they are requested.

{
  "id_token": { "auth_time": { "essential": true } },
  "userinfo": { "email": null, "email_verified": null }
}

essential, value, values

Each requested claim can specify:

  • essential: true — the client really needs it.
  • value — request that the claim equals a specific value.
  • values — request one of several allowed values.
{ "acr": { "essential": true,
            "values": ["urn:mace:incommon:iap:silver"] } }

Sending It in the Request

The JSON is URL-encoded and sent as the claims query parameter on the authorization request.

GET /authorize?response_type=code
  &client_id=app123&scope=openid
  &claims=%7B%22id_token%22%3A%7B%22auth_time%22%3A%7B%22essential%22%3Atrue%7D%7D%7D

Why Not Just Scopes?

Scopes bundle many claims at once. The claims parameter is for when you need precision — a single specific claim, an essential requirement, or a constraint on its value. It complements scopes rather than replacing them.

Aggregated Claims

Sometimes claims come from a third party the OP trusts. Aggregated claims are bundled by the OP as a signed JWT from the external claims provider and returned inline, so the client gets verifiable assertions without extra calls.

Aggregated Claims Format

The OP references them via _claim_names (which claim came from which source) and _claim_sources (the JWT holding them).

{
  "_claim_names": { "address": "src1" },
  "_claim_sources": {
    "src1": { "JWT": "eyJhbGciOi..." }
  }
}

Distributed Claims

Distributed claims are not embedded; instead the OP gives an endpoint and access token so the client can fetch them directly from the external source when needed.

{
  "_claim_names": { "payment_info": "src2" },
  "_claim_sources": {
    "src2": {
      "endpoint": "https://bank.example.com/claims",
      "access_token": "ksj3n283dke"
    }
  }
}

Aggregated vs Distributed

The trade-off:

  • Aggregated — claims travel inline, fewer round-trips, larger token.
  • Distributed — claims fetched on demand, smaller token, extra request and live availability of the source.

Processing External Claims

For aggregated claims, verify the embedded JWT's signature against the claims provider's keys. For distributed claims, call the endpoint with the supplied access token and validate the returned JWT before trusting any values.

When to Use These

External claim mechanisms shine in federations: an identity provider asserts who you are, while a bank or government source asserts verified attributes. They keep sensitive data at its authoritative source.

Quick Check

Test your understanding of claim requests.

Recap

The claims parameter enables fine-grained, essential, or value-constrained claim requests targeting the ID token or UserInfo.

  • essential, value, and values refine each request.
  • Aggregated claims are embedded inline as signed JWTs.
  • Distributed claims are fetched from an external endpoint.
  • Always verify external claim signatures before trusting them.
เริ่มต้นได้ฟรี

เรียนรู้ OAuth2 & OpenID Connect Deep Dive ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “คำขอ Claims และ Claims แบบรวม” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “คำขอ Claims และ Claims แบบรวม” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส OAuth2 & OpenID Connect Deep Dive ให้อัปเกรดเป็น CoddyKit PRO คอร์ส OAuth2 & OpenID Connect Deep Dive มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “คำขอ Claims และ Claims แบบรวม”

เรียนรู้วิธีที่ OpenID Connect ให้ไคลเอนต์ขอ Claims เฉพาะรายการด้วยพารามิเตอร์ claims และวิธีที่ Claims แบบกระจายและแบบรวมส่งคำยืนยันจากแหล่งข้อมูลภายนอก คุณปฏิบัติ OAuth2 & OpenID Connect Deep Dive ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน OAuth2 & OpenID Connect Deep Dive หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน OAuth2 & OpenID Connect Deep Dive บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “คำขอ Claims และ Claims แบบรวม” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน OAuth2 & OpenID Connect Deep Dive นี้ได้ไหม

ได้ บทเรียน OAuth2 & OpenID Connect Deep Dive ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การลงทะเบียนไคลเอ็นต์แบบไดนามิก
  2. ปลายทางการค้นหา OIDC
  3. การจัดการเซสชัน
  4. คำขอ Claims และ Claims แบบรวม
← กลับไปที่ OAuth2 & OpenID Connect Deep Dive