Choosing which messages to protect
OpenID ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. lets several of its messages be signed, encrypted or both, and each layer has a cost. This lesson follows a security review of the collage app's sign-in, message by message, asking for each one who reads it along the way and who needs to check afterwards where it came from.
Messages that can be protected
Before launching the student discount from Combining claims from multiple sources, the collage company asks for a security review of its sign-in. The reviewer follows each message from where it is created to every place it is read, and two findings stand out. All domains, identifiers and tokens in these examples are fictional.
The first is the authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. request. When Ava chooses the discount, it carries a claims parameter asking for her Northfield enrollment status, and it travels through her browser's address bar, its history, any extension allowed to read page addresses, and the photo service's request logs. Anyone who sees it learns that the collage app asked whether Ava is a student. The second is the UserInfoAn OpenID Provider endpoint that returns claims about the signed-in person to a client presenting an access token. Its sub must match the ID token's before the client uses anything it returns. response. HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest. protects it only as far as the hosting company's load balancer, the front server where the connection ends. From there it crosses the collage company's internal network to the collage app's sign-in service, and Ava's name, email address and student status are then passed on to a separate order service, which has to take the sign-in service's word for where they came from.
OpenID Connect allows four of its messages to be signed with JSON Web SignatureThe JOSE format for signed content, defined in RFC 7515. A signed JWT is a JWS: a header, a payload and a signature, each base64url-encoded and joined by dots. (JWS), encrypted with JSON Web EncryptionThe JOSE format for encrypted content, defined in RFC 7516, which only holders of the right key can read. A JWT is sent as a JWE when its claims must stay confidential, not just protected from change. (JWE), or both: the ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs., the UserInfo response, the request objectAn OAuth extension, RFC 9101, that puts the authorization request's parameters in a signed JWT called a request object. The authorization server can then tell they came from the client and were not changed in the browser., and the JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. a client uses to authenticate itself, its client assertion. Related specifications protect others in the same way, such as JARMAn OpenID Foundation extension that returns the authorization response, including the code and state, inside a JWT signed by the authorization server. The client checks the signature before it uses the code. for authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. responses. The defaults differ:
| Message | Created by | By default | Can also be |
|---|---|---|---|
| Authentication request | The collage app | Plain parameters in the browser's address | A request object, signed by the collage app, encrypted to the photo service, or both |
| Authorization response | The photo service | Plain parameters in the redirect | Signed, and optionally encrypted to the collage app, with JARM |
| ID token | The photo service | Signed, apart from one narrow case | Also encrypted to the collage app |
| UserInfo response | The photo service | Plain JSON | Signed, encrypted to the collage app, or both |
| Client assertion | The collage app | Used only with JWT-based client authentication | Always signed when used, and can also be encrypted |
A message is signed with its creator's private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. and encrypted with its reader's public key. The specifications also allow keys derived from a confidential client's secret, but a shared secret cannot show which of the two sides produced a message, so this group uses key pairs throughout. The JAR lessons and JARM lessons in Advanced OAuth applied these protections to requests and authorization responses. This group applies them to the messages OpenID Connect adds.
What a signature adds
Each protection should answer a question that someone actually needs answered. For a signature, the question is who needs to check where a message came from, and when.
For the ID token, the specification has already answered: ID tokens are signed. The one unsigned case, which Signing keys and rotation described, needs a client that registered for it, and the collage app never has.
A UserInfo response usually is not signed at all. The collage app requests it directly over HTTPS with its own access token, and checks that its sub matches the ID token. That connection shows the answer came from the photo service, but it shows this only to the sign-in service, and only while the connection lasts. The order service in the reviewer's second finding never saw that connection. If the photo service signs the response, the sign-in service can pass the signed JWT along, and the order service can verify it with the photo service's public key without trusting anything in between. A signed UserInfo response must also contain iss and aud, so the order service can check that it was the photo service's statement, made for the collage app.
Over HTTPS only
- Sign-in service knows the sender
- Order service can check who wrote it
- Unreadable past the load balancer
The order service takes the sign-in service's word.
Signed by the photo service
- Sign-in service knows the sender
- Order service can check who wrote it
- Unreadable past the load balancer
Carries iss and aud for the order service.
Signed, then encrypted
- Sign-in service knows the sender
- Order service can check who wrote it
- Unreadable past the load balancer
The collage app's choice for UserInfo.
Anyone can encrypt to a public key, so an encrypted message on its own says nothing about who wrote it.
For the request, the reasoning runs the other way: the photo service is the one that needs to know the request is genuine. OpenID Connect's security considerations note that parameters such as max_age and acr_values give the provider more assurance about the authentication being requested when they arrive in a signed request, and the claims parameter is no different. The collage app still checks auth_time and acr in the ID token itself, as Session age and reauthentication and Authentication context and methods taught. The JAR lessons covered what a signed request object proves and how a provider validates one.
What encryption adds
For encryption, the question is who can read a message between the moment it is created and the moment its intended reader opens it.
The request object passes through the browser, which is exactly where the reviewer's first finding arose. Signing it hides nothing, because anyone holding a signed JWT can decode it. OpenID Connect's security considerations describe this case: knowing that a client asked for a particular claim, or a particular authentication method, can itself reveal something about the person. Encrypted to the photo service's public key, the request object keeps the claims request out of the address bar, history and logs, in a form only the photo service can open. Sending the object by reference, or pushing it with PAR, also keeps it out of the address bar. Encryption protects its contents wherever it is stored or passed along.
The ID token is a different case. With the code flow, it travels directly from the token endpoint to the collage app's backend over HTTPS, and in this example it contains no profile claims at all. Encryption matters more where an ID token passes through the browser, as it does in the implicit and hybrid flows covered in Response types, response modes, and older flows, or where a provider places sensitive claims in it. One detail catches out relying parties that do receive encrypted ID tokens. To send one later as an id_token_hint, the relying party must decrypt it and send the signed token inside, which it may encrypt again to the provider's own key.
The UserInfo response was the reviewer's second finding. Encrypted to the collage app's public key, it stays unreadable from the moment the photo service sends it until it reaches the one component that holds the collage app's private key, past the load balancer, the internal network and anything along the way that records request or response bodies.
Encryption has limits. Anyone can encrypt to a public key, so an encrypted message on its own says nothing about who wrote it, and encryption does nothing to stop a copied message being delivered again. It also hides the contents from the collage company's own monitoring, which is sometimes the point and sometimes an obstacle.
The collage app's choices
With those questions answered message by message, the collage company decides:
| Message | Decision | Reason |
|---|---|---|
| Request object | Signed with the collage app's key collage-2026-10, then encrypted to the photo service, every time | The photo service can rely on what the collage app asked for, and nobody along the way can read it. Encrypting only the requests that ask about enrollment would make exactly those requests stand out. |
| Authorization response | Unchanged: a code, state and iss, with PKCE | It carries nothing worth hiding, and PKCE protects the code. JARM remains available if the collage app later wants signed responses. |
| ID token | Signed only | It arrives directly from the token endpoint and contains no profile claims. |
| UserInfo response | Signed, then encrypted to the collage app | The order service can verify the signature, and the encryption protects Ava's profile past the load balancer. |
Each choice has a cost. The collage app must now publish an encryption key and replace it from time to time, the photo service must support every algorithm the collage app picks, and each added layer brings more algorithm combinations that both implementations must support and test. A provider that does not list an encryption algorithm in its discovery metadata cannot be asked to use it.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Review how your tenant protects each OIDC messageDo the lesson's security review on Lab Photos. Follow each message, record how it is protected by default, ask for more protection where the tenant offers it, and read exactly what the tenant answers.