Żądanie claims i zagregowane claims
Dowiedz się, jak OpenID Connect pozwala klientom żądać określonych claims za pomocą parametru claims oraz jak claims rozproszone i zagregowane dostarczają asercje ze źródeł zewnętrznych.
Żądanie claims i zagregowane claims to bezpłatna lekcja OAuth2 & OpenID Connect Deep Dive na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej OAuth2 & OpenID Connect Deep Dive, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs OAuth2 & OpenID Connect Deep Dive zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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%7DWhy 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, andvaluesrefine 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.
Ucz się OAuth2 & OpenID Connect Deep Dive dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 12
- Lekcje
- 48
Często zadawane pytania
Czy lekcja „Żądanie claims i zagregowane claims” jest bezpłatna?
Tak — pełny tekst „Żądanie claims i zagregowane claims” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu OAuth2 & OpenID Connect Deep Dive, przejdź na CoddyKit PRO. Kurs OAuth2 & OpenID Connect Deep Dive zawiera 4 lekcji w sumie.
Co nauczysz się w „Żądanie claims i zagregowane claims”?
Dowiedz się, jak OpenID Connect pozwala klientom żądać określonych claims za pomocą parametru claims oraz jak claims rozproszone i zagregowane dostarczają asercje ze źródeł zewnętrznych. Ćwiczysz OAuth2 & OpenID Connect Deep Dive z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć OAuth2 & OpenID Connect Deep Dive?
Nie wymagamy żadnego doświadczenia. OAuth2 & OpenID Connect Deep Dive w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Żądanie claims i zagregowane claims”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji OAuth2 & OpenID Connect Deep Dive?
Tak. Każda lekcja OAuth2 & OpenID Connect Deep Dive zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Dynamiczna rejestracja klienta
- Punkt końcowy OIDC Discovery
- Zarządzanie sesją
- Żądanie claims i zagregowane claims