Table des matières

🇫🇷 Français | 🇬🇧 English


JWT and UserInfo

Objective

During an authentication through LINLP, several elements are returned:

👉 This page explains their role and usage.


Overview

Element Role
id_token Contains identity data (signed JWT)
access_token Allows API calls
/userinfo Allows retrieval of user data

⚠️ Key Recommendation: Retain the id_token

⚠️ The id_token must be retained by the partner.

👉 It constitutes:

👉 Indeed:

💡 This enables:


ID Token (JWT)

The id_token is a signed JSON Web Token containing:


JWT Structure

A JWT is composed of 3 parts:

HEADER.PAYLOAD.SIGNATURE

Example JWT (decoded)

{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "abc123"
}

Payload

{
  "sub": "075ccece-6699-4c08-80ca-27a6af136b68",
  "given_name": "Jean Pierre",
  "family_name": "Dupont",
  "preferred_username": "Martin",
  "birthdate": "1990-05-10",
  "email": "jean.dupont@mail.com",
  "iat": 1710000000,
  "exp": 1710003600,
  "iss": "https://authent.lidentitenumerique.laposte.fr",
  "aud": "client_id"
}

Important Points

⚠️ The payload is readable A JWT is not encrypted, only signed.

⚠️ Never trust it without validation Always verify the signature.


JWT Validation

The partner must:


Access Token

The access_token:

👉 It should not be used directly to read user data.


/userinfo Endpoint

Allows retrieval of user data through API:

GET /userinfo
Authorization: Bearer access_token

Example Response

{
  "sub": "075ccece-6699-4c08-80ca-27a6af136b68",
  "given_name": "Jean Pierre",
  "family_name": "Dupont",
  "email": "jean.dupont@mail.com"
}

id_token vs userinfo

Criteria id_token /userinfo
Format JWT JSON
Signature Yes No
Usage Authentication User data

Best Practices

⚠️ Retain the id_token It is verifiable proof of authentication.

⚠️ Always validate the JWT Signature + expiration are mandatory.

⚠️ Do not expose tokens Never on an unsecured frontend.

⚠️ Use HTTPS only Secure transport is mandatory.


Points of Attention

⚠️ The access_token is sensitive Protect it like a password.


Summary


Next Step

👉 Test the integration:

Create a Test Identity