Migrating an identity provider
Moving an 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. to a new platform has to carry across everything its relying parties depend on, much of which nobody wrote down. This lesson follows the photo service's migration: password hashes and lazy migration, 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. and subjects the collage app stores for Ava, running both systems side by side, cutover and rollback, and telling people.
Moving the front door
The photo service has signed people in with its own system for ten years. That system issues the ID tokens the collage app validates when Ava Archer signs in, the SAMLThe Security Assertion Markup Language, a federation standard widely used for workplace single sign-on, in which the identity provider sends the application a signed assertion about the user. assertions an older greeting-card partner relies on, and the sessions behind every album. It is also showing its age, and the photo service has decided to move to a new identity platform. For its customers and partners, the goal is that nothing visible happens at all: the same sign-in page, the same accounts, the same connected applications, on a different engine.
That is harder than it sounds, because an identity provider is depended on in ways nobody wrote down. Relying parties store identifiers it issued. Browsers hold its cookies. Password hashes, authenticatorSomething a person controls and uses to prove control of an account, such as a memorized password, an app that generates one-time codes, or a security key. It counts only after it has been registered to that account. registrations and refresh tokens were all made in formats the new platform did not choose. A migration that moves only the user table breaks every one of those quietly, usually on the morning after cutover. Migrating older integrations retired old patterns inside one authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate.; this lesson moves the whole server.
| What | Why it is hard |
|---|---|
| Accounts and profiles | The easy part, if attribute names and formats are mapped carefully |
| Passwords | Stored only as hashes, which cannot be turned back into passwords |
| Second factors and passkeys | Secrets and public keys tied to the old system and its domain |
| Subject identifiers and the issuer | Stored by every relying party as the key to each account |
| Clients, signing keys and metadata | Registered and cached by relying parties |
| Sessions, refresh tokens and consents | Live state that people notice the moment it disappears |
Bringing passwords across
The old system never stored passwords, only hashes of them, as Passwords and PINs explained. A hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash. cannot be reversed, so passwords cannot be exported. What can be exported is the hash itself, if the new platform can check passwords against it.
Most of the photo service's accounts have bcrypt hashes, which describe themselves:
$2b$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW2b names the algorithm, 12 the cost, and the next 22 characters are the 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., followed by the hash. A new platform that understands bcrypt can import this string and check passwords against it at the next sign-in. When the check succeeds, it holds the plaintext password for that moment, so it rehashes it with its own preferred algorithm, such as Argon2id, and discards the imported hash. Over a few months, every active account moves to the new format without anyone choosing a new password.
About 4 percent of accounts are older still, from before the photo service adopted bcrypt, and have salted SHA-1 hashes that the new platform will not accept, rightly, because SHA-1 is far too fast for passwords. One option is to wrap them: compute bcrypt over each old SHA-1 hash now, store that, and at sign-in compute SHA-1 then bcrypt over the typed password. That protects the old hashes immediately, but needs the new platform to support the custom combination. The photo service chose the other option for these accounts.
Lazy migration
In a lazy migration, accounts move one at a time, at the moment their owner signs in. The new platform holds every profile from the first day but no password for these accounts. When one of them signs in, it asks the old system, over a private connection, whether the password is right. If the old system says yes, the new platform stores its own hash and marks the account as migrated; the old system is never asked about that account again.
The private verification endpoint is the riskiest piece. It accepts passwords for any account, so it must accept requests only from the new platform, authenticate them, be rate-limited like a sign-in page, and never be reachable from the internet. It also inherits the old system's answers, so a locked or disabled account must be refused there too, not migrated.
Lazy migration has a long tail: people who sign in once a year will still be unmigrated a year later. The photo service set a date six months after cutover. Accounts still unmigrated then are sent through a password reset at their next sign-in, and the old system, with its endpoint, is switched off.
Second factors need the same care. Authenticator-app seeds can be exported if the old system can export them, and they must travel encrypted. Passkeys are bound to 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. ID, the photo service's domain. If the new platform keeps the same relying party ID, each passkeyA credential that your phone, computer or password manager creates for one website and keeps for you, unlocked with a fingerprint, face or PIN. Nothing you could type is sent, and it works only for the site it was made for, which helps it resist phishing.'s credential ID and public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. can be imported and keep working; if the domain changes, every passkey has to be registered again.
Keeping subjects and issuers
The collage app knows Ava as the pair (https://auth.photos.example, user-2048), the issuer and subject from her first 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., because OpenID Provider responsibilities promised that a subject is never reassigned and never changes. The new platform generates its own user IDs, such as 0f3c9a1e-77b2-4c8e-9d1a-5a4f2e6b8c30. If it put that value in sub, the collage app would receive 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. for a person it has never seen.
What happens next depends on the collage app, and none of it is good. It might create a second, empty account, so Ava's collages seem to vanish. It might fall back to matching on her email address, the shortcut Connecting a sign-in to an account warned against. Multiply that by every relying party and every user, and a changed subject is a mass account-takeover risk as well as a support disaster.
So the subject moves with the account. The photo service imports each user with the old identifier kept as an attribute, and configures the new platform to issue that value as sub to every existing relying party. Pairwise subjects must be recalculated with the same sector identifiers and the same secret, so each relying party keeps receiving the same value. SAML is no different. Its assertions name the person with a NameID, and a persistent NameID plays the part of a stable subject, so the greeting-card partner's persistent NameID values must carry over exactly.
The issuer has to stay the same too. Relying parties compare iss exactly and store it with the subject, and they fetch discovery and keys from it. The photo service keeps https://auth.photos.example by serving the new platform on that hostname. It also publishes the new platform's signing key in its key set a few weeks before cutover, next to the old one, so relying parties that cache keys already know it when the first token signed with it arrives, the rollover described in Signing keys and rotation.
Running both side by side
Few migrations switch every application on one night. The photo service moves its relying parties in waves, starting with its own applications, where it controls both sides, then the collage app and other OpenID Connect clients, and last the SAML partner. During the waves both systems are live, and each application is sent to one of them.
Two arrangements make that work. In one, the new platform answers at the old hostname and passes the protocols it has not taken over yet to the old system behind it. In the other, the new platform acts as a broker: to the applications not yet moved it is their provider, and out of sight it signs people in through the old system and passes the result on. Whatever passes through a broker must arrive with the same identifiers and the same meaning, or the applications behind it open the wrong accounts. Running SAML beside OpenID Connect, in the SAML lessons, follows a broker that also translates between protocols.
Each wave is tested against real relying parties before it goes live, using a test environment with copies of their registrations. The test that matters most is the dull one: sign in as an existing user through the new platform and confirm the relying party opens the same account as yesterday.
Cutover and rollback
On the night of a wave's cutover, traffic for that wave moves to the new platform. Existing sessions in the old system end, so people sign in once more. Refresh tokens are the sharpest edge: the collage app holds refresh tokens the old system issued, which the new platform cannot honor unless they were migrated with their grants. The photo service migrated the grants and their consents, so Ava's year-end collage keeps arriving each December; without that, every connected application would have needed her to approve it again.
A plan to go back is part of the plan to go forward. Until a wave's point of no return, the old system stays ready, and every change made in the new platform that the old one would need, such as a new account, a changed password or a removed authenticator, is copied back to it. Rolling back is then a routing change. After the point of no return, which the photo service set at two weeks per wave, changes stop flowing back, and fixing forward is the only direction.
Telling people
A migration that works technically can still fail through surprise. The photo service wrote to three audiences, each with what they needed.
Customers were told the date, that they would be asked to sign in once more, and that the photo service would never ask for their password by email, because a migration announcement is a phishing template waiting to be copied. Relying party owners received the dates, the test environment, and a list of what would stay identical, the issuer, the subjects and the endpoints, together with the one thing that would change, the new signing key, weeks ahead. The help desk received the expected questions and a way to tell a migrated account from an unmigrated one, since most calls in the first week would be about passwords that worked yesterday.
When the last wave passed its point of no return and the long tail of resets was done, the old system was switched off. The collage app never noticed: its stored pair still matched, its keys had already been fetched, and Ava's collages were where she left them.
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
- Bring an imported account across: its old identifier, its password and its first sign-inTreat a person Start created as an imported profile, record the old system's identifier, see a legacy password refused, store the password a lazy migration verified, and compare the subject the new platform issues.