GitHub Enterprise Managed Users with Microsoft Entra ID - Part 2

If you haven't already, please check out the previous parts of this series.
Part 2 - You're reading it now!
Introduction
In this post, we will walk through the process of creating a new GitHub Enterprise with Managed Users. We will not be using the Data Residency feature. For authentication, we will connect to Microsoft Entra ID using OpenID Connect (OIDC). And, finally, for user provisioning we will setup Microsoft Entra ID using System for Cross-domain Identity Management (SCIM).
Creating a new GitHub Enterprise
The process to create a new Enterprise involves signing up for a free trial, which you can do here: https://github.com/account/enterprises/new.
First, you must choose between an Enterprise with Managed Users, or an Enterprise with Personal Accounts. Reminder: for this blog series, we will be using Managed Users.
Next, you must choose if you want to use Data Residency or not. Reminder: for this blog series, we will NOT use Data Residency.
Both of the above choices are fully covered in part 1 of this series. So, if you need a refresher please go read part 1.
Then, you must fill in some more information about your new Enterprise. This includes things such as the Enterprise name you want to use, the URL slug you want to use, and the shortcode you want to use.
The URL slug will be used to access your Enterprise, like so: https://github.com/enterprises/<slug>
The shortcode is important to understand, as this can NOT be changed later. This must be 3-8 alphanumeric characters. When new users are provisioned, an underscore character and the shortcode will be appended to the end of each username, like so: <username>_<shortcode>. The shortcode will also be used for the admin account username, but more on that below.
You must select which Identity Provider you will be using. Reminder: for this blog series, we will be using Microsoft Entra ID.
Finally, you must specify a name and e-mail address for the admin account. This is a special account that is only used for the first-time setup process. This will be the ONLY account in your Enterprise that is not provisioned by your identity management system. The username for this admin account is hard-coded and follows this pattern: <shortcode>_admin
First Time Setup
The first thing you'll need to do is reset the password for the admin account and then login with that account so that we can complete the first time setup process. You should receive an email containing a link which you can use to reset the password for the admin account. This will be sent to the e-mail address that you specified in the sign up process that we discussed earlier. Once you login you will be taken to a landing page where you must complete 3 steps:

Step 1 - Generate SCIM token
While logged in with the admin account, you must create a Personal Access Token (Classic). This token will be used in Step 3 to configure user provisioning.
This token needs to be configured with no expiration date and only needs a single scope for "scim:enterprise". Once you generate the token, make sure to copy the value and store it in a safe place, as you will not be able to view it later.
Step 2 - Enable Single Sign-on
In this step we will configure Entra ID single sign-on, which supports two options: OIDC or SAML. GitHub recommends OIDC as this allows you to utilize Conditional Access Policies. Note: a single Entra ID tenant can only be connected to a single GitHub Enterprise using OIDC. If you want to connect this same Entra ID tenant to additional GitHub Enterprises, then you must use SAML for the other ones.
The GitHub web UI will walk you through the process of creating a new Enterprise App in Entra ID. It will automatically transfer you to the Azure Portal in order to create the Enterprise App. The app will have a name of "GitHub Enterprise Managed User (OIDC)". Make sure to enable the option for "Consent on behalf of your organization" as this is required. Note: in order to select this option, you must be logged into Azure with an account that has global admin permissions.
After the Entra ID App setup is complete, you will then be transferred back to the GitHub portal. You will be prompted to download a set of recovery codes for single sign-on. Make sure to store these codes in a safe place. Then, finally you can click on the button to "Enable OIDC authentication".
Step 3 - Configure Provisioning
Note: there are 2 ways that you can configure user provisioning. One, GitHub accounts will be provisioned based on which users/groups are assigned to the Entra App. Or two, GitHub accounts will be provisioned based on specific attributes that can be configured on each Entra user/group. For this blog series, we will show the first option, by manually assigning users/groups to the Entra App.
We need to create a new provisioning configuration on the Enterprise App. So, in the Azure Portal, go to the newly created Enterprise App, click on "Provisioning", and then click on "New Configuration". Here you will enter a few pieces of information:
Tenant URL: this will be the SCIM URL for the new Enterprise, and it follows this format: https://api.github.com/scim/v2/enterprises/<slug> where <slug> is the value you selected in the sign up process that we discussed earlier.
Secret token: this will be the PAT that you created earlier in Step 1.
With that information entered you can click on "Test Connection". If that works then you can click on "Create".
We are not quite done yet! We must go into the properties of this new provisioning configuration and modify a few more settings:

If the user provisioning process has an error it will enter a "quarantine" state. Wouldn't it be nice if you could get an email when this happens? Well, as you can see in the screenshot above, you can enter a "Notification email" which will receive alerts any time this happens.
Next, you can modify the "Accidental deletions" settings. This helps protect you when you make a mistake that would result in many GitHub users being removed at one time. For example, say you accidentally deleted a group in Entra ID that contained 800 users. Normally, the provisioning process would want to remove all 800 users from GitHub. But, if you select "Prevent accidental deletion" with a "threshold" lower than 800, then you will be protected. In this example, the provisioning process will be paused and placed into a "quarantine" state until you can diagnose and resolve the issue.
The last couple of settings deal with "Provisioning scope". A user can fall out of the provisioning scope for many reasons. Maybe they were removed from a group, or their account was disabled, or something else happened. When this occurs what will happen to the user account in GitHub? This is determined by the setting "Skip out of scope deletions" which will be discussed in more detail below. You must also choose the "Scope" that you want to provision, will it be all users/groups in Entra, or only the ones that have been assigned to the Enterprise App?
Once all of your settings are properly configured, you can click on "Start Provisioning". When one or more users are successfully provisioned to GitHub, then this third and final step of the setup is complete!
Extra Step - Two-Factor Authentication
Before you logout from the Admin Account you may want to do one more thing, and that is setup two-factor authentication on the account. Go into the account's profile settings and configure 2FA as desired.
Final Setup Diagram

Deep Dive on User Provisioning
Before we wrap up part 2, I want to do a deep dive on a few topics related to the SCIM user provisioning process.
Assignment to the Enterprise App
Assigning users to the Enterprise App
This is available for any tier of Entra ID, even the free tier.
A GitHub account will be provisioned for every user that you assign to the Enterprise App.
Assigning groups to the Enterprise App
This is not available on the free tier of Entra ID, it requires P1 or P2 licensing.
A GitHub account will be provisioned for every direct member of the group.
Nested groups are NOT supported. When you assign a group to an application, only users in the group have access. The assignment doesn't cascade to nested groups.
You can assign an Entra "Security" Group or an Entra "Microsoft 365" Group to the Enterprise App. However, it might be best to stick with "Security" Groups only. I say that because if you want this Entra Group to be connected to a GitHub Team, then it must be a "Security" Group. (more on this is coming in Part 3 of the blog series)
Enterprise App Roles
When you assign a user/group to the Enterprise App you must also select a "role" for that user/group to assume. Below you will see the default App Roles that are available.
The "Enterprise Owner" app role will grant the user/group the "Owner" role at the GitHub Enterprise level ... in other words, this is very powerful so be careful who you assign this role to.
The "User" app role is a basic role and will grant the user or group the "Base Permission" to your Enterprise. In your GitHub Enterprise policies, you get to choose what the "Base Permission" has access to, so this is up to you.

GitHub Usernames
Finally, let's talk about the usernames for your provisioned GitHub accounts. The GitHub usernames will be auto-generated, and will follow this pattern: <handle>_<shortcode>. We've discussed <shortcode> before, so you should already know what that is. But, what is <handle>? It is taken from the "User Principal Name" (UPN) of the account, with some extra modification:
It uses only the text before the @ symbol
For guest accounts, this does NOT include the #EXT# text
GitHub usernames can only contain alphanumeric characters and the dash character. Any special characters in the UPN will be changed to a dash.
The username, including the underscore and the shortcode, must not exceed 39 characters total.
Wrapping up and Summary
Okay, that covers everything that I wanted to discuss about doing the first time setup of your Enterprise. We talked about a lot, including how to sign up for a new Enterprise, how to setup SSO, how to configure user provisioning, and finally we went into detail about a few topics that are important to know about provisioning.
Next up in the series we will cover how to connect GitHub Teams to Entra ID Groups. Stay tuned!

Comments