Sub topic 15
Authorizing tokens and keys for SAML SSO organizations
This chapter assumes you can create a personal access token, add an SSH key to your GitHub account, and run basic Git commands over HTTPS or SSH. Some organizations add one more requirement on top of those steps. You will learn what that requirement is, how to meet it, and how to recognize the error when you haven't.
What SAML SSO changes
Some organizations require members to sign in through the company's identity provider (IdP). This is called SAML single sign-on (SSO). The IdP is the system that holds the company's accounts, such as Okta or Microsoft Entra ID.
Signing in to the website through the IdP does not carry over to Git. A token or SSH key belongs to your personal GitHub account. It has no access to the organization's private repositories until you authorize it for that organization. The authorization is a separate step, and you do it once for each credential.
This is the authentication and authorization split from earlier in the tutorial. Your token or key proves who you are. The SSO authorization is the organization's approval to use that credential on its resources.
Authorizing a personal access token
- Open GitHub's token settings: Settings, Developer settings, Personal access tokens.
- Find the token and select Configure SSO next to it.
- Select Authorize beside the organization.
- Sign in through your IdP if GitHub asks you to.
Authorize only the organizations the token needs. A fine-grained token is tied to one resource owner chosen when you create it, so you pick the organization at creation time. Some organizations also require approval for fine-grained tokens, and an owner may need to approve the token before it works.
If you create the token while signed in through SSO, authorization can be part of the creation flow. Check the token list afterward to confirm.
Authorizing an SSH key
- Open Settings, SSH and GPG keys.
- Find the key and select Configure SSO.
- Select Authorize beside the organization.
After this, Git operations over SSH to that organization's repositories work with the same key. You don't change the remote URL.
Recognizing the failure
An unauthorized credential produces a rejection that mentions SAML enforcement. A typical HTTPS message looks like this:
remote: The 'ExampleOrg' organization has enabled or enforced SAML SSO.
remote: To access this repository, you must use the HTTPS remote with a personal access token or SSH with an SSH key and passphrase that has been authorized for this organization.
fatal: unable to access 'https://github.com/ExampleOrg/repo.git/': The requested URL returned error: 403Your other repositories keep working. Only the SSO organization's repositories fail, which separates this problem from a wrong password or a missing key.
Two behaviors are worth knowing:
- Authorization is per credential. A new token or a new SSH key needs its own authorization.
- Access can lapse. If the organization ends your SSO session or you leave the IdP, the credential stops working until you authorize it again.
Credentials created by gh auth login are also authorized this way. If gh signs in but cannot reach the organization, check the token in your settings and authorize it.
Exercise
You can push to your personal repositories, but a push to an SSO-enforced organization's repository returns a 403 that mentions SAML SSO. Your token is valid and has the repo scope. What do you do?
Show answer
Open Settings, Developer settings, Personal access tokens, select Configure SSO beside the token, and authorize it for the organization. The token proves your identity, but the organization requires a separate approval for each credential. You don't need a new token or a new remote URL.