DEV Community

Daniel Pertu
Daniel Pertu

Posted on

We replaced GitHub sign-in with Microsoft, and the provider id in our code is neither of those words

Our product is assessment practice for job candidates: graduate schemes, police forces, air traffic control, the public sector. The two social sign-in buttons we shipped with were Google and GitHub, and GitHub was there because the person who built the auth page had GitHub open at the time. Almost nobody applying for a police constable role has a GitHub account.

So we swapped it for Microsoft, which is the account a lot of our visitors already have through a university or an employer. Four things about that were not obvious.

The provider id is azure

The server action is one line of real work:

export async function signInWithMicrosoft() {
  if (MAINTENANCE) {
    redirect('/maintenance');
  }

  const url = await signInWithOAuthProvider('azure');
  if (url) {
    redirect(url);
  }
}
Enter fullscreen mode Exit fullscreen mode

Supabase's provider key for Microsoft sign-in is azure, not microsoft, so the union on the helper went from 'google' | 'github' to 'google' | 'azure'. That name then leaks in two directions and we stopped it in both.

Outwards, into the UI: nothing a user reads says Azure. Inwards, into analytics, the callback maps it:

const provider = user.app_metadata?.provider;
const method: SignupMethod =
  provider === 'google' || provider === 'github'
    ? provider
    : provider === 'azure'
      ? 'microsoft'
      : 'oauth';
Enter fullscreen mode Exit fullscreen mode

github stays in that union forever, because rows captured with it are already in the warehouse and a chart that groups by sign-up method should not lose its history when a button goes away.

Microsoft does not send the email address unless you ask

Google hands back the address without being asked. Microsoft does not. Our users table has a not-null email column and the Stripe customer is keyed on it, so an account without an address is not a degraded account, it is a broken one.

One conditional option, in the shared helper rather than in the action:

const { data } = await supabase.auth.signInWithOAuth({
  provider,
  options: {
    redirectTo: `${PUBLIC_URL}/auth/callback`,
    // Supabase's "azure" provider is Microsoft sign-in. Microsoft only returns
    // the address when the `email` scope is asked for, and the account row
    // needs it.
    ...(provider === 'azure' ? { scopes: 'email' } : {}),
  },
});
Enter fullscreen mode Exit fullscreen mode

This is the shape I keep reaching for when two providers legitimately differ: one spread on the key that differs, not two copies of the function.

Verified by Microsoft is not the same as verified by us

We have a wall in front of checkout: an account created with an email address must confirm the address before it can buy, because the receipt, the licence and every lifecycle email go to it, and a typo there produces a customer we cannot reach.

OAuth users never see that wall, because the identity provider has already confirmed the address and Supabase stamps email_confirmed_at accordingly. That is true of Google. It is true of Microsoft only when the app registration sends the xms_edov optional claim. Without it the address arrives unverified, and a Microsoft user hits a confirm step at checkout that a Google user does not.

That is a configuration fact, not a code fact, which is exactly the kind of thing that is invisible in a diff six months later. It went into the doc comment on the module that owns the wall:

 * OAuth users are verified by construction - Google (and GitHub, for older
 * accounts) only hand back addresses they have confirmed, and Supabase stamps
 * `email_confirmed_at` accordingly - so the wall is invisible to them.
 * Microsoft does the same only when the Azure app registration sends the
 * `xms_edov` optional claim; without it Supabase treats a Microsoft address as
 * unconfirmed and the buyer is asked to confirm it at checkout.
Enter fullscreen mode Exit fullscreen mode

Domain verification is 112 bytes

Microsoft wants to know the app is allowed to speak for the domain, and the way you tell it is a static file holding one application id and nothing else. Ours is 112 bytes, served from public/.well-known/.

Two notes on that, both learned from the Android version of the same idea:

The file has to be at /.well-known/<name>.json at the root. Serving the same JSON from an API route under a different path produces a 200 that the verifier never looks at. We lost an afternoon to exactly that with Android's assetlinks.json earlier in the year.

Our robots.txt carries Disallow: /*.json in both of its user-agent groups, so this file is disallowed for crawlers, as assetlinks.json is. That is fine. Neither Microsoft's verifier nor Android's reads robots.txt, and a domain-verification file is not a page anybody should find in search.

The copy was the long part

The actual surprise in the diff is how little of it is code. The provider name is written in prose on three policy pages: twice in the privacy policy, once in the terms, once in the cookie policy. A swapped button means a legal-copy change, and it means somebody has to decide whether that change bumps the policy version a user has to re-accept.

We decided it does not. The data categories are identical, the processor role is identical, and the only difference is which company's name sits in the sentence. CURRENT_PRIVACY_VERSION stayed at 1.10.0 and those four lines went out as an edit, not a new version. The judgement call is more interesting than the edit: a version bump means every signed-in user sees a re-consent prompt, so bumping it for a brand name trains people to click through the prompt without reading it.

The string github still appears in eight files across the repository. Three of them are about sign-in: the analytics union, the callback's mapping, and that doc comment. The rest are an interview guide where an example answer mentions a candidate's own GitHub, a cron comment that lists GitHub Actions as an example scheduler, our IndexNow workflow path, and two citations pointing at an Air Force practice test hosted on github.io. A rename is never the whole grep.

See it

Fetch the verification file, which is public and is meant to be:

curl -s https://cogniprep.app/.well-known/microsoft-identity-association.json
Enter fullscreen mode Exit fullscreen mode

You get 112 bytes, one associatedApplications array, one application id.

Then open cogniprep.app/login and you will find exactly two provider buttons, Google and Microsoft, with the Microsoft mark drawn as four coloured squares in its own colours, which is what Microsoft's own branding guidance asks for. Search the HTML for "Continue with Github" and you get nothing.

The policy copy is checkable too. cogniprep.app/privacy says "Google and Microsoft" in two places and still reads "Version: 1.10.0" at the top, which is the call described above, in one page.

Worth knowing if you are planning the same swap: everything above is on the Supabase and Microsoft side of the line. The two interesting bits, the scope and the xms_edov claim, are both things you configure once, in a console, and then cannot see from your own repository at all.

Top comments (0)