Public and pairwise subject identifiers
The subject an 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. carries is also a key that can join records about a person across applications. This lesson compares public subjects, which every client receives alike, with pairwise subjects, which differ per client, and shows how sector identifiers keep pairwise subjects stable for related applications.
One identifier for everyone
The collage app is not the only application Ava signs in to with her photo account. The printer offers the same button, and she used it last spring to order a printed calendar. Both applications validated an ID tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. from the photo service and stored the subject it carried. Each now holds a record about Ava, her collages in one and her print orders in the other. Whether anyone outside the photo service can join those two records depends on the value each one stored. All domains, identifiers, and values in these examples are fictional.
The photo service uses public subject identifiers. Every client receives the same sub for the same account, so the printer and the collage app both stored user-2048.
That is simple, and often exactly right. Inside one company, a project portal and a timesheet app might both receive employee-42 from the company's identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider., and the company wants them to. Both applications belong to the same organization, and matching an employee's records across them is part of running the business.
Between unrelated companies, the same property works against the person. If the printing company and the collage company share customer data, sell it, or come under the same owner, user-2048 is a ready-made key for joining their records. Ava's print orders and her collages, which she gave to two separate companies, become one profile. Nobody had to guess or match on fuzzy details, because the photo service handed both companies the same value. Joining records about a person across services like this is called correlation, and a public subject makes it effortless.
A different identifier for each client
A provider can use pairwise subject identifiers instead, giving each client its own sub for the same person. The mail service works this way. When Ava signs in to the printer with her mail account, the printer receives 7e21c0d95b. If she signed in to the collage app with the same mail account, it would receive a different value:
| Provider | Subject type | The printer receives | The collage app receives |
|---|---|---|---|
| Photo service | Public | user-2048 | user-2048 |
| Mail service | Pairwise | 7e21c0d95b | a94f1c07e2 |
Compare the two mail service values and they share nothing. Only the mail service knows that both belong to Ava.
The provider calculates a pairwise value from the person's account and the client it is issuing to. Any method will do, provided it gives the same answer every time for the same person and client, a different answer for a different client, and an answer that nobody except the provider can trace back to the account. One example in the specification hashes three values joined together: a sector identifier, explained below, the account's internal identifier, and a secret saltA random value stored with each password hash and mixed into the calculation, so that two people with the same password get different stored hashes. It does not need to be secret. that only the provider knows:
sub = SHA-256(sector_identifier || local_account_id || secret_salt)Another is to generate a random value for each pairing and store it. The printer never needs to know which method a provider uses. It never calculates a subject. It receives one and stores it with the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts., exactly as it does with user-2048, and looks Ava up by that pair.
A provider lists the types it offers in subject_types_supported in its discovery documentA JSON document that an OpenID Provider publishes at a well-known address under its issuer, listing its endpoints, where to find its signing keys, and its supported features so clients can configure themselves from one value., such as ["public", "pairwise"]. Where it offers both, a relying partyAn application that accepts and relies on a sign-in from another service, the name used in OpenID Connect and for passkeys. SAML calls the same role a service provider. chooses with the subject_type setting in its registration, as Registering a relying party mentioned. Some providers issue pairwise values to every client and offer no choice.
Pairwise subjects remove one easy way to correlate Ava. They do not make her anonymous. If the printer and the collage app both receive her email address, [email protected] joins their records just as well as user-2048 did. Some claims carry an identifier inside them. The photo service's picture address, https://photos.example/avatars/user-2048.jpg, contains her public account number, so a provider that switched to pairwise subjects but kept addresses like that would still hand every client the same key. Pairwise identifiers also limit what relying parties can learn by comparing notes, not what the provider knows. The mail service issued every one of those values and knows where it sent each of them. How much privacy Ava gains depends on everything else that is released, which Claim stability and privacy takes further.
Sector identifiers
"A different identifier for each client" is not quite precise. A pairwise subject is calculated for a sector identifier, and every client in the same sector receives the same value.
By default, the sector identifier is the host of the client's registered redirect URI. The printer's registration with the mail service has one return address, https://printer.example/signin/mail/callback, so its sector is printer.example, and 7e21c0d95b is Ava's subject for that sector. That default has two consequences.
First, related applications on different hosts are kept apart. Suppose the printing company's phone app also offers sign-in with a mail account, under its own registration, returning to https://app.printer.example/signin/mail/callback, a claimed 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. address like the one in Redirect URIs and client metadata. Its sector would be app.printer.example, so the app would receive a different subject for Ava than the website does. The printer, which finds accounts by issuer and subject, would not find Ava's account when she signed in through the app.
Second, a move changes every subject. If the printing company later moved its website's sign-in pages to www.printer.example, the sector would change with them, and every returning customer would arrive with a new subject that matches no account. The only remaining clue would be details such as email addresses, which Claim stability and privacy explains are no basis for finding an account.
Both problems have the same remedy. A registration can include a sector_identifier_uri, an HTTPS address of a JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. file listing redirect URIs. The provider then uses the host of that address as the sector identifier. The printing company publishes one file and names it in both registrations:
GET /oidc/redirect-uris.json HTTP/1.1
Host: printer.example
HTTP/1.1 200 OK
Content-Type: application/json
[
"https://printer.example/signin/mail/callback",
"https://app.printer.example/signin/mail/callback"
]
Registration setting, website and app:
"sector_identifier_uri": "https://printer.example/oidc/redirect-uris.json"When it accepts each registration, the mail service fetches the file and refuses the registration unless every one of that client's redirect URIs appears in it. The sector for both clients is now printer.example, the host of the file's address. The website and the app both receive 7e21c0d95b for Ava, and because printer.example was the website's sector all along, no existing subject changes. A later move works the same way: the company adds the new return address to the file and to its registration, keeps serving the file from printer.example, and subjects stay as they were. A registration whose redirect URIs span more than one host must name a sector identifier file, because the provider would otherwise have no single host to use.
The list of redirect URIs is what keeps outsiders out of the sector. The file is served from printer.example, so only the printing company decides which return addresses belong there. The collage company cannot register a client with this sector_identifier_uri, because its own redirect URIs are not in the file, and so it cannot receive the subjects the printer receives.
Whatever its type, a subject has the same properties. It is unique within its issuer and never reassigned to another person. It is a case-sensitive string of at most 255 ASCII characters, so the printer stores it exactly as received, in a field long enough for 255 characters, and never assumes it is a number or changes its case. And it is not a secret. Knowing that someone is user-2048 at the photo service does not let anyone sign in as them. A pairwise value limits who can connect records about a person. That is a privacy protection, not a credential.
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
- Correlate two clients through a public subject, then give each sector its ownJoin the printer's and the collage app's records about Ava through her public sub, see why a prefix does not stop it, then switch both clients to pairwise subjects and choose which clients share a sector.