Configuring SAML Single Sign-On

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 9 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Configuring SAML Single Sign-On for GitHub

Introduction: Why Identity Management Matters in Development

In the modern software development lifecycle, security is no longer just a perimeter defense; it is about managing the identity of every individual interacting with your source code. As organizations scale, managing individual usernames and passwords for every single tool in the stack becomes a nightmare for both IT administrators and developers. This is where Security Assertion Markup Language (SAML) Single Sign-On (SSO) becomes a critical component of your security architecture. By centralizing authentication, you ensure that when a developer leaves the company or changes roles, their access to critical infrastructure—like your GitHub repositories—is revoked instantly across the board.

SAML SSO allows your organization to use an existing Identity Provider (IdP), such as Okta, Azure Active Directory (Microsoft Entra ID), or PingFederate, to authenticate users before they access GitHub. Instead of GitHub handling the password validation, it offloads that responsibility to your trusted IdP. This creates a unified login experience, improves security posture through mandatory multi-factor authentication (MFA) enforced at the IdP level, and significantly reduces the administrative burden of account lifecycle management. This lesson explores the mechanics of SAML, the configuration process for GitHub, and the operational best practices required to maintain a secure development environment.


Not read yet

Understanding the SAML Workflow

To configure SAML effectively, you must first understand the "handshake" that happens between your Identity Provider and GitHub. SAML is an XML-based framework that allows secure communication between two parties: the Service Provider (GitHub) and the Identity Provider (your internal directory service).

The Authentication Sequence

  1. Request: A user attempts to access a resource on GitHub (e.g., github.com/orgs/my-company).
  2. Redirect: GitHub identifies that the organization requires SAML SSO. It generates a SAML authentication request and redirects the user's browser to the pre-configured URL of your Identity Provider.
  3. Authentication: The user logs in to your IdP. If they have already logged in, the IdP may skip the prompt. The IdP verifies the user's credentials and, if necessary, checks for MFA.
  4. Assertion: The IdP generates a SAML assertion—a cryptographically signed XML document containing information about the user (such as their email address or unique ID).
  5. Verification: The browser sends this assertion back to GitHub. GitHub verifies the digital signature against the public certificate you provided during setup.
  6. Access: If the signature is valid, GitHub grants the user access to the organization.

Callout: SAML vs. OAuth While both are used for authentication and authorization, they serve different purposes. OAuth 2.0 is primarily designed for authorization, allowing an application to access resources on behalf of a user without sharing their password. SAML is specifically designed for authentication, acting as a "passport" that confirms who you are to a service. In the context of GitHub, we use SAML to control who can access the organization, while OAuth tokens are used by applications to perform actions on behalf of the user within that organization.


Not read yet

Prerequisites for Configuration

Before you dive into the technical configuration, you need to ensure your environment is prepared. Attempting to configure SAML without these prerequisites will lead to failed connections and potential lockout scenarios.

  • GitHub Enterprise Cloud or Business Plan: SAML SSO is a premium feature available on GitHub Enterprise. Ensure your subscription tier supports it.
  • Identity Provider Access: You must have administrative access to your organization’s IdP (e.g., Okta, Azure AD, OneLogin). You will need to create a new "Application" within that IdP.
  • Organization Ownership: You must be an owner of the GitHub organization you are configuring.
  • Verified Domain: It is highly recommended to verify your domain on GitHub before enabling SAML. This ensures that you own the email address space associated with your users.
  • Test Account: Always have a "break-glass" account—an administrator account that is not tied to the SAML SSO process—in case the configuration fails or the IdP goes down.

Not read yet

Step-by-Step Configuration Guide

Step 1: Create the Application in your Identity Provider

Every IdP has a slightly different interface, but the core requirements remain identical. You need to create a new SAML 2.0 application.

  1. Select SAML 2.0: Choose the "SAML 2.0" template or "Custom SAML App" option in your IdP.
  2. Entity ID: Provide the GitHub Entity ID, which is usually https://github.com/orgs/YOUR-ORGANIZATION-NAME.
  3. Assertion Consumer Service (ACS) URL: This is the URL where the IdP sends the SAML assertion. For GitHub, it is https://github.com/orgs/YOUR-ORGANIZATION-NAME/saml/consume.
  4. NameID Format: Set the NameID format to EmailAddress. This is the most common and recommended format to ensure GitHub can map the user correctly.
  5. Attributes: You must map specific user attributes. GitHub expects the following:
    • email: The user's primary email address.
    • first_name and last_name (optional but recommended for user profiles).

Step 2: Configure GitHub Organization Settings

Once the IdP side is ready, you need to tell GitHub to listen for these assertions.

  1. Navigate to your GitHub organization settings.
  2. Select Security in the left sidebar, then Authentication security.
  3. Check the box to Enable SAML authentication.
  4. Sign-on URL: Enter the login URL provided by your IdP (the endpoint where GitHub sends authentication requests).
  5. Issuer: Enter the unique entity ID provided by your IdP.
  6. Public Certificate: Upload the X.509 certificate provided by your IdP. This certificate is what GitHub uses to verify that the incoming SAML assertion truly came from your IdP and not an attacker.

Step 3: Testing the Connection

Do not enable enforcement immediately! First, use the "Test SAML configuration" button. This allows you to verify that the handshake works without locking out your current members. If the test fails, GitHub will provide an error message detailing the specific XML attribute or signature mismatch that caused the failure.

Tip: The Break-Glass Account Always designate at least two organization owners who are excluded from the SAML mandate or have an "emergency" recovery path. If your IdP experiences an outage, these accounts ensure you can still manage your organization's security settings and repository access.


Not read yet

Mapping SAML Assertions: A Technical Deep Dive

The most common point of failure in SAML integration is the "mapping" of user identities. GitHub identifies users by their email address. If the email address sent by your IdP does not match the email address associated with the user's existing GitHub account, the link will fail.

Handling Attribute Mismatches

If your IdP sends [email protected] but the developer has their personal GitHub account set up with [email protected], you have a conflict. The user will be unable to access the organization. You have two options here:

  1. Email Reconciliation: Instruct the developer to add their corporate email to their existing GitHub account and verify it. GitHub will then recognize the corporate email as part of the SAML assertion.
  2. SCIM Provisioning: If you are using an advanced IdP, you can use System for Cross-domain Identity Management (SCIM) to automatically provision users and manage their email addresses, removing the manual burden from the developer.

Example: SAML Assertion Structure

When your IdP sends an assertion, it looks similar to the following XML structure. Understanding this helps when you are debugging failed logins:

<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_123456789">
  <saml:Subject>
    <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
      [email protected]
    </saml:NameID>
  </saml:Subject>
  <saml:AttributeStatement>
    <saml:Attribute Name="email">
      <saml:AttributeValue>[email protected]</saml:AttributeValue>
    </saml:Attribute>
  </saml:AttributeStatement>
</saml:Assertion>

In this snippet, the NameID is the critical field. GitHub scans this field to find a user account that matches [email protected]. If the NameID is missing or in the wrong format, the authentication process will terminate with an "Identity Provider response invalid" error.


Not read yet

Best Practices and Industry Standards

1. Enforce MFA at the Identity Provider

The primary benefit of SAML is centralizing the security policy. By forcing MFA at the IdP level, you ensure that every developer is protected by your company’s standard (e.g., hardware keys like YubiKeys or push notifications). Do not rely on GitHub’s internal MFA if you have a robust IdP; disable GitHub-specific MFA for members if your IdP already enforces it.

2. Implement Just-in-Time (JIT) Provisioning

If your GitHub plan supports it, use JIT provisioning. This allows a user to be automatically added to your organization the first time they sign in via SAML. This reduces the time an administrator spends manually inviting new hires to the GitHub organization.

3. Regular Certificate Rotation

SAML certificates have an expiration date. When they expire, all authentication will stop working, effectively locking everyone out of the GitHub organization. Create a calendar reminder for 30 days before the certificate expires to update it in both your IdP and GitHub.

4. Audit Your SAML Logs

Both GitHub and your IdP provide logs. If users are complaining about login issues, check the IdP logs first to see if the assertion was generated successfully. Then, check the GitHub audit log (under your organization settings) to see if GitHub rejected the assertion.

Callout: The "SAML Lockout" Scenario If you enable SAML enforcement and realize your IdP configuration is incorrect, you might find yourself unable to log in to manage the settings. This is why you must maintain "Recovery Codes" or have an organizational owner who is a "GitHub-native" user (not linked to SAML) to disable the enforcement if a catastrophe occurs.


Not read yet

Common Pitfalls and Troubleshooting

Troubleshooting "403 Forbidden" Errors

A 403 error during SAML login usually means the user has successfully authenticated with the IdP, but GitHub does not recognize them as a member of the organization. This happens if:

  • The user is not in the "Assigned Users" list of the application within your IdP.
  • The email address sent by the IdP does not match any email address verified on the user's GitHub account.
  • The user has not yet accepted the invitation to join the organization.

Troubleshooting "Signature Validation Failed"

This is almost always a mismatch between the certificate uploaded to GitHub and the one the IdP is using to sign the assertion. Ensure you are downloading the metadata or the public certificate specifically for the SAML signing, not the encryption certificate.

Handling User Offboarding

When an employee leaves, your priority is to remove their access. If you have configured SAML correctly, disabling or deleting the user in your IdP (e.g., in Active Directory) will automatically prevent them from authenticating via SAML. However, they might still have cached personal access tokens (PATs). Always ensure your security policy includes revoking any active PATs or SSH keys associated with the departed user.


Not read yet

Comparison Table: SAML Configuration Options

Feature SAML SSO (Basic) SCIM Provisioning
Authentication Handled by IdP Handled by IdP
User Onboarding Manual Invite Automatic (JIT)
User Offboarding Manual Removal Automatic (Sync)
Attribute Sync None Real-time updates
Best For Small/Mid-sized teams Large organizations

Advanced Configuration: SCIM

While SAML handles the "Who are you?" part of the equation, SCIM handles the "What are your permissions?" part. SCIM (System for Cross-domain Identity Management) is a protocol that allows your IdP to automatically push user profile information to GitHub.

When you add a user to the "GitHub Group" in your IdP, SCIM sends a signal to GitHub to create that user account automatically. If you remove the user from the group, SCIM sends a signal to GitHub to revoke their access. This is the gold standard for secure identity management. If your organization is large enough to warrant SAML, you should strongly consider implementing SCIM to eliminate the manual overhead of managing member lists.

Implementing SCIM

  1. Generate a Personal Access Token: You will need a GitHub PAT with admin:org and admin:enterprise scopes.
  2. Enter Credentials in IdP: In your IdP's provisioning settings, enter the SCIM endpoint URL provided by GitHub and the PAT.
  3. Configure Mapping: Map your IdP groups to GitHub teams. This allows you to manage repository permissions directly from your IdP.

Not read yet

Summary and Key Takeaways

Configuring SAML SSO is one of the most impactful security decisions an organization can make for its GitHub environment. It moves your security from a fragmented, per-user model to a centralized, policy-driven model that scales with your company.

Key Takeaways:

  • Centralization is Security: Use your Identity Provider as the single source of truth for all user authentication. This ensures that when a user leaves the company, their access to code is terminated immediately.
  • Always Test Before Enforcement: Never enable SAML enforcement without first running the test utility. A misconfiguration can lead to a total lockout of your organization's administrative team.
  • The Break-Glass Strategy: Always maintain at least one or two non-SSO administrative accounts. These accounts serve as your safety net if your Identity Provider experiences downtime or if your certificate configuration fails.
  • Email Matching is Critical: Ensure that the NameID attribute sent by your IdP matches the verified primary email address on the developer's GitHub account. Discrepancies here are the #1 cause of login failure.
  • Plan for Certificate Rotation: SAML relies on X.509 certificates. Treat these like any other security credential—track their expiration dates and update them well in advance to prevent service disruptions.
  • Consider SCIM for Scale: If you find yourself manually adding and removing users from your organization, look into SCIM provisioning. It automates the lifecycle of your users and significantly reduces the risk of orphaned accounts.
  • Audit Regularly: Use the GitHub audit logs to periodically review who is accessing your organization and verify that your SAML configuration is behaving as expected.

By following these practices, you ensure that your development environment remains secure, compliant, and easy for your team to navigate. Identity management is a continuous process, not a "set it and forget it" task; stay vigilant, keep your certificates updated, and always test your configurations in a staging environment if possible.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.