Configure OIDC for GitHub Enterprise EMU using a user created in the target tenant, not a guest user
This page has been translated by machine translation. View original
Hello! I'm Yoshida from the Cloud Business Division.
This happened while I was configuring Microsoft Entra ID OIDC for Enterprise Managed Users (EMU) authentication in a GitHub Enterprise Cloud Enterprise that I use for testing. I meant to set it up in my test tenant, but I accidentally registered the "GitHub Enterprise Managed User (OIDC)" app in my account's home tenant (our company's production tenant). The tenant's administrator deleted the app right away, and there was no actual damage.
This article summarizes what happened, why the app was registered in the home tenant, and how to prevent it. I think it is most likely to happen to people who have been invited to test tenants or customer tenants and move back and forth between multiple tenants.
Key points: cause and prevention
There are two causes:
- The consent screen that opens during EMU OIDC setup is opened with the
commonendpoint, which does not specify a tenant - An account invited from another tenant signs in to its home tenant when using
common
When these two overlap, even if you consent with an account invited to the test tenant, the app is registered in the home tenant. To be safe, perform the OIDC setup with a user created in the target tenant. In addition, on the consent screen, expand the permission items and check which tenant the consent applies to before accepting.
What happened
The environment was as follows:
- The GitHub Enterprise Cloud Enterprise was created as an EMU
- For Entra ID, I use a test tenant separate from the home tenant where my account exists
- My account was created in the home tenant, and was invited to the test tenant as a guest with the Global Administrator role
- In the home tenant, I am not an administrator
The tenant IDs in this article have been replaced. 11111111-… is the test tenant and 22222222-… is the ID of the home tenant.
I proceeded with the OIDC setup following the steps in the GitHub documentation. After switching the directory to the test tenant in the Microsoft Entra admin center, I opened "Identity provider" → "Single sign-on configuration" of the GitHub Enterprise in the same browser. When I selected "Enable OIDC configuration" and clicked "Save", I was taken to the Entra ID consent screen.

I clicked "Accept" on this screen, and completed saving the recovery codes and enabling it. When I looked at the SSO settings after setup, the Tenant ID contained the home tenant's ID (22222222-…) instead of the test tenant's.

When I searched the test tenant's enterprise applications for "GitHub Enterprise Managed User (OIDC)", there were 0 results. Even though I am not an administrator in the home tenant, the app had been registered in the home tenant.

The OIDC setup consent screen opens with the common endpoint
The first pitfall is that the consent screen during setup opens without specifying a tenant.
Comparing the URLs of the Entra ID screens during setup and during SSO sign-in after setup reveals the difference.
| Scenario | URL of the Entra ID screen |
|---|---|
| When setting up OIDC (consent screen) | https://login.microsoftonline.com/common/oauth2/v2.0/authorize |
| SSO sign-in after setup | https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/oauth2/v2.0/authorize (test tenant ID) |
After setup, the URL contained the test tenant's ID. Here is the consent screen at that time.

During setup, GitHub doesn't yet know which tenant to connect to, so it is presumably using common. Once setup is done, the registered tenant's ID is put in the URL. The URL during setup is determined by GitHub, so the user cannot specify the tenant.
The behavior of the common endpoint is explained in Microsoft Learn as follows:
When the Microsoft identity platform receives a request on the
/commonendpoint, it signs the user in and, as a consequence, discovers which tenant the user is from.
Convert single-tenant app to multitenant on Microsoft Entra ID - Microsoft Learn
In other words, which tenant the consent applies to is determined by the account that signed in.
An invited account signs in to its home tenant
The second pitfall is which tenant an invited account signs in to.
During the work, I was viewing the test tenant in the Microsoft Entra admin center, and I had Global Administrator.


The reason I still consented to the home tenant is that specifying a tenant is required to sign a guest account in to another tenant.
Critically, for guest scenarios where you sign a user from one tenant into another tenant, you must provide the tenant identifier to correctly sign them into the resource tenant.
(Translation: Importantly, in guest scenarios where you sign a user from one tenant into another tenant, you must provide the tenant identifier to correctly sign them in to the resource tenant.)
OpenID Connect (OIDC) on the Microsoft identity platform - Microsoft Learn
Because common does not specify a tenant, my account presumably signed in to the home tenant and consented there. Switching directories in the admin center only changes what is displayed in the admin center. It had no bearing on which tenant I would sign in to after being redirected from GitHub.
What decides the tenant you sign in to is the account's home tenant. It is not whether the user type (UserType) is guest or member.
Microsoft Learn classifies users by the tenant where the account exists and UserType as follows. Accounts from other tenants can be invited as either guests or members.
| Type | Tenant where the account exists | UserType in the target tenant |
|---|---|---|
| Internal member | Target tenant | Member |
| External member | Other tenant | Member |
| External guest | Other tenant | Guest |
My account in this case is an external guest. When this article says "a user created in the target tenant", it means an internal member. The same page also explains that UserType is unrelated to how a user signs in.
UserType has nothing to do with how the user signs in, the directory role of the user, and so on. This property simply indicates the user's relationship to the host organization and allows the organization to enforce policies that depend on this value.
Properties of a B2B guest user - Microsoft Learn
Therefore, the same result is likely to occur even with an account invited as an external member (I haven't tested this).
The consent screen doesn't show the tenant unless you expand the items
The third issue is that it is hard to tell the tenant on the consent screen.
The consent screen from when I consented by mistake showed the account's email address and the app name. Since I use the same account in both the home tenant and the test tenant, the email address doesn't tell me which tenant it is.
I noticed later, when I redid the setup, that expanding the permission items (such as "View your basic profile") shows which tenant's data the access applies to.

When I consented by mistake, I accepted with the items still collapsed. If I had expanded them, I should have noticed that it was consent to the home tenant.
Reverting and redoing the setup
Here are the key steps so that you can revert if the same thing happens. For detailed operations, refer to the GitHub documentation.
Have the mistakenly registered app deleted
I had the tenant's administrator delete the enterprise application "GitHub Enterprise Managed User (OIDC)" in the home tenant. Since this was before SCIM provisioning and user assignment, the only impact was that the app had been registered.
Disable OIDC in GitHub
Open "Single sign-on configuration" with the setup user and disable OIDC single sign-on. In the confirmation dialog, enter the Enterprise name and click "I understand, disable OIDC single sign-on".

Immediately after disabling, "Previous OIDC provider is being removed" was displayed, and for a while I couldn't click the button to reconfigure.

Redo the setup with a user created in the test tenant
I prepared an administrator user created in the test tenant (an internal member, in Microsoft's documentation terms) and redid the setup in a window with no sessions from other tenants remaining. Here is the consent screen at that time.

On the first acceptance, the following error appeared on the GitHub screen.

AADSTS650051: Consent action for Application '12f6db80-0741-4a7e-b9c5-b85d737b3a31' failed due to following error: The 12f6db80-0741-4a7e-b9c5-b85d737b3a31 service principal name is already present for the tenant 11111111-1111-1111-1111-111111111111
This is a consent conflict error that occurs when a service principal already exists in the tenant. The tenant ID in the error is the test tenant's, so we can tell that this time it is pointing to the correct tenant. When I repeated the same operation, I proceeded to the recovery codes screen and the setup completed. Presumably, the first attempt updated the state of the service principal, and the second attempt was able to connect using the existing one.
After completion, the Tenant ID in the SSO settings became the test tenant's ID, and the app was also registered in the test tenant.

How to prevent it
Before EMU OIDC setup, and before accepting on the consent screen, check the following points:
- Perform the setup with a user created in the target tenant. Don't get by with a guest invited from another tenant and given Global Administrator
- Work in a window with no sessions from other tenants remaining
- On the consent screen, expand the permission items and confirm that the target tenant's name appears before accepting
- After setup, confirm that the Tenant ID in GitHub's SSO settings is the target tenant's ID
Note that a single Entra ID tenant can connect only one EMU Enterprise via OIDC. If the app remains in the wrong tenant, it can also get in the way when connecting another EMU to that tenant via OIDC, so it seems best to delete it early once you notice.
Each Entra ID tenant can support only one OIDC integration with Enterprise Managed Users.
Configuring OIDC for Enterprise Managed Users - GitHub Docs
Conclusion
In this article, I summarized the cause of, and how to prevent, accidentally registering the app in an unintended tenant during GitHub Enterprise EMU OIDC setup. It happens when the setup consent screen opening with common and an invited account signing in to its home tenant overlap. I think you can prevent it simply by performing the setup with a user created in the target tenant and expanding the items on the consent screen to check the tenant name.
I hope this helps someone.
That was Yoshida from the Cloud Business Division!