OAuth2 & OpenID Connect Deep Dive · Lektion

Standardmäßige ID-Token-Claims validieren

Lernen Sie die erforderlichen Validierungsschritte für die Claims iss, aud, exp, iat und nonce eines OpenID-Connect-ID-Tokens kennen.

Lektion 4 von 413 Schritte

Standardmäßige ID-Token-Claims validieren ist eine kostenlose OAuth2 & OpenID Connect Deep Dive-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des OAuth2 & OpenID Connect Deep Dive-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der OAuth2 & OpenID Connect Deep Dive-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Signature Is Not Enough

Verifying an ID token's signature proves it came from the provider, but you must also validate its claims to ensure it was meant for you, right now, and is still valid. A valid signature on a token meant for another app is still dangerous.

Validate iss (Issuer)

The iss claim must exactly equal the issuer identifier of your trusted provider, as published in its discovery document. Reject anything else.

if (claims.iss !== 'https://op.example.com') reject();

Validate aud (Audience)

The aud claim must contain your client_id. If aud is an array with multiple values, an azp (authorized party) claim must be present and equal your client_id.

const auds = Array.isArray(claims.aud) ? claims.aud : [claims.aud];
if (!auds.includes(MY_CLIENT_ID)) reject();

Validate exp (Expiration)

The exp claim is a Unix timestamp. The current time must be before exp. Reject expired tokens; allow a small clock skew (a few minutes) at most.

const now = Math.floor(Date.now() / 1000);
if (now >= claims.exp) reject('expired');

Validate iat (Issued At)

The iat claim says when the token was issued. You can reject tokens that are unreasonably old, and use iat to enforce freshness policies.

if (now - claims.iat > MAX_AGE_SECONDS) reject('too old');

Validate nonce

If you sent a nonce in the authentication request, the token's nonce must equal the value you stored. This blocks replay.

if (claims.nonce !== session.nonce) reject('nonce mismatch');

Check azp When Present

The azp (authorized party) claim identifies which client the token was issued to when there are multiple audiences. If present, it must match your client_id.

auth_time and max_age

If you requested max_age or auth_time is essential, verify the auth_time claim shows the user authenticated recently enough; otherwise force re-authentication.

Order of Operations

A safe sequence:

  • Decode and verify the signature (correct alg + key).
  • Validate iss, aud/azp.
  • Validate exp, iat (and auth_time if needed).
  • Validate nonce.

Only after all pass do you trust the identity.

A Combined Check

Bringing the claim validations together:

function validateClaims(c, cfg, now) {
  if (c.iss !== cfg.issuer) throw 'bad iss';
  const auds = [].concat(c.aud);
  if (!auds.includes(cfg.clientId)) throw 'bad aud';
  if (now >= c.exp) throw 'expired';
  if (c.nonce !== cfg.nonce) throw 'bad nonce';
  return true;
}

Use a Vetted Library

Hand-rolling JWT validation invites subtle bugs (alg confusion, skew handling). Prefer a well-maintained OIDC/JWT library and only configure the policy; let it enforce signature and claim checks.

Quick Check

Check your claim-validation knowledge.

Recap

Validating ID token claims goes beyond the signature:

  • iss must match the trusted issuer; aud must include your client_id.
  • exp/iat enforce validity and freshness (allow small skew).
  • nonce blocks replay; check azp with multiple audiences.
  • Prefer a vetted library over hand-rolled checks.
Kostenlos starten

Lerne OAuth2 & OpenID Connect Deep Dive mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
48

Häufig gestellte Fragen

Ist die Lektion „Standardmäßige ID-Token-Claims validieren“ kostenlos?

Ja — der vollständige Text von „Standardmäßige ID-Token-Claims validieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des OAuth2 & OpenID Connect Deep Dive-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der OAuth2 & OpenID Connect Deep Dive-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Standardmäßige ID-Token-Claims validieren“?

Lernen Sie die erforderlichen Validierungsschritte für die Claims iss, aud, exp, iat und nonce eines OpenID-Connect-ID-Tokens kennen. Du übst OAuth2 & OpenID Connect Deep Dive mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um OAuth2 & OpenID Connect Deep Dive zu starten?

Keine Vorkenntnisse erforderlich. OAuth2 & OpenID Connect Deep Dive auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Standardmäßige ID-Token-Claims validieren“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser OAuth2 & OpenID Connect Deep Dive-Lektion Code schreiben und ausführen?

Ja. Jede OAuth2 & OpenID Connect Deep Dive-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Aufbau und Signatur des ID Tokens
  2. JWS und JWK-Sets
  3. Token-Widerruf und Introspection
  4. Standardmäßige ID-Token-Claims validieren
← Zurück zu OAuth2 & OpenID Connect Deep Dive