Enforcing two-factor authentication in self-managed GitLab

Enforce 2FA on self-managed GitLab instance-wide, per group or for administrators only, with grace periods, TOTP and WebAuthn, API automation and recovery for users locked on the setup page.

On this page

Enforcing two-factor authentication in self-managed GitLab: when teams need it

A CISO or identity lead who must require a second factor for GitLab accounts first has to choose a scope: the whole instance, administrators only, or specific groups. Each scope carries a different lockout risk. Instance-wide enforcement reaches every developer and every sign-in path that depends on a GitLab-managed password, so it belongs at the end of a rollout, not the start. Before choosing, inventory who signs in, how they sign in, and which groups hold the highest-impact permissions. That inventory decides whether administrators-only enforcement is enough for the first phase, and whether a grace period for unenrolled users is needed before the setting takes effect.

GitLab's two-factor setting governs the password sign-in path directly. Accounts that sign in through SAML, LDAP or another external provider are a different case, and the setting does not replace MFA in the identity provider. Treat these as two controls with separate owners: the identity provider decides whether a user passes a second factor when signing in through SSO, and GitLab decides whether a local sign-in needs one. The GitLab authentication documentation describes each supported provider. For your version, confirm in writing which external sign-in paths GitLab's setting reaches before you tell users what to expect.

Decide early which factors you will accept. The GitLab documentation for your version should confirm whether time-based one-time passwords, WebAuthn security keys or both are available for enrollment, and whether recovery codes are issued. Test the full path with a non-administrator account in a staging instance: enrollment, a sign-in from a new browser, recovery, and an API call made with a personal access token. Those tests show which teams need help before enforcement begins, and they produce the evidence that a change-control or access review will ask for.

Choosing the enforcement scope: instance, group or administrators

Instance-wide enforcement applies one two-factor requirement to every user account on the GitLab instance. It fits organizations where all accounts, including managed contractors, fall under the same policy and where the security team wants a single setting to audit. Administrators configure it in the Admin Area sign-in settings, and a grace period gives users time to enroll before sign-in is blocked.

  • Broadest reach: every account is covered, so service accounts and shared accounts need a documented exception path or a separate design.
  • Simplest audit: one setting answers the question of which population must enroll.
  • Grace period planning: users who have not enrolled when the period ends cannot sign in until they set up a method, so the communication plan matters as much as the setting.
  • Upstream identity: confirm how SAML or LDAP users who authenticate through an external provider are handled by the two-factor check in your version.

Before you announce a date, check the grace period behavior and the service account treatment in the GitLab authentication documentation for your version.

Configuration options and when each fits

This table compares the main 2FA enforcement choices in self-managed GitLab: instance-wide versus group or admin-only scope, grace periods, allowed factors and API-driven automation. Read each row as a decision point, then confirm exact setting names and availability for your GitLab version in the authentication documentation before you change production settings.

Setting or choiceWhat it controlsWhen it fits
Instance-wide 2FA requirementRequires every user to set up two-factor authentication before continuing to use the instanceOrganizations with uniform access policy and few service or bot accounts that cannot complete a 2FA prompt
Administrator-only enforcementRequires two-factor authentication for users with administrator rights onlyStaged rollouts where privileged accounts must be protected first and general users follow later
Group-level enforcementRequires two-factor authentication for members of a specific group and its subgroupsTeams with different risk profiles, such as a regulated product group within a larger instance
Grace periodTime window in which users can defer setup before sign-in is blockedRollouts that need communication, helpdesk capacity and device enrollment time before hard enforcement
TOTP authenticator appsOne-time codes from an authenticator app as a second factorBroad baseline coverage for users on personal or managed devices with few hardware requirements
WebAuthn security keysHardware or platform passkeys as a second factorPrivileged users and higher-assurance groups; confirm which WebAuthn options your version and browsers support
Recovery codesOne-time backup codes issued at setup for account recoveryAny rollout; plan who resets lost factors and how identity is verified before a reset
API settings for automationProgrammatic reads and updates of 2FA-related configuration, including scripted rollout stepsLarge instances or repeatable rollouts across environments; use scoped admin tokens and log changes
Locked users on the setup pageAccounts that reach the setup page and cannot proceed until they enroll a factorService accounts and unmanaged users need an owner and a plan before enforcement reaches them

Setup sequence for a 2FA rollout

This sequence moves a self-managed GitLab instance from optional to enforced two-factor authentication without locking out the people who run it. Each step ends with a check you can record, so the rollout produces evidence of scope, timing and verified behavior.

  1. Confirm the second factors users can register

    Decide which second factors your users may register, such as authenticator app codes (TOTP) and hardware security keys (WebAuthn), and whether any account types need separate handling. List human accounts, bot and service accounts, and users who sign in only through SSO, because each group may be affected differently by the policy. Confirm each choice against the GitLab authentication and authorization documentation for your version. Done when the factor list and affected account types are written down and approved by the security owner.

  2. Pilot enforcement with administrator accounts

    Scope the first enforcement to administrator accounts, ideally on a non-production instance or with a small set of admins. Sign in as each pilot admin from a fresh browser session and confirm the instance prompts for a second factor, that a factor can be registered from the setup page, and that the admin can reach normal pages afterward. Repeat with each factor type you plan to offer. Done when every pilot admin has signed in successfully with each permitted factor and the results are recorded.

  3. Set the grace period and communication plan

    Choose the grace period your GitLab version supports, and confirm in the documentation what happens to users when it expires. Write a notice that states the deadline, the accepted factors, the setup steps and the support contact, then send it through the channels your users read. Export the list of users without a registered factor so support can follow up before enforcement. Done when the notice is approved, support knows the recovery path, and the pending-user list is saved.

  4. Enable enforcement at the chosen scope

    Turn on the enforcement setting for the scope you chose: instance-wide, administrators only, or specific groups. Use the path your GitLab version documents, and make the change during a planned window. Record who made the change, when, and the exact setting, then confirm the admin area shows the intended value. Done when the configuration matches the approved scope and the change is logged in your change management system.

  5. Verify sign-in, setup page and existing sessions

    Sign in with a test account in scope and confirm it is prompted for a second factor. Check that a user without a registered factor lands on the setup page and cannot reach project content. Compare the behavior of existing browser sessions and personal access tokens with what the documentation says for your version, and test one CI job and one scripted API call that depends on a token. Done when each observed behavior matches the documented behavior, and any difference is logged with a fix or an approved exception.

  6. Track pending users and close the rollout

    Review the pending-user list against the grace period schedule and follow up with people who have not registered a factor. Handle exceptions through a documented recovery process that an administrator runs, and confirm that recovery does not weaken the policy for others. Keep the notice, scope record, test results and exception log together as evidence for your auditors. Done when no user is locked out unexpectedly, every exception has an owner and an end date, and the rollout record is filed.

Using the API for 2FA settings in automation

Script 2FA settings through the API when the same configuration has to be applied repeatedly, for example across several self-managed GitLab instances, across development, staging and production copies, or when a rollout must be reproduced exactly after a rebuild. The admin UI works well for a single instance changed once, but it leaves no reviewable artifact and depends on someone remembering each click. A script turns the 2FA policy into something a reviewer can read, test against a non-production instance and run the same way every time.

Before any script touches production, the automation needs three things. First, a token from an administrator account with only the scope the task requires, stored in your secrets manager and rotated on a schedule, not kept in a shell history or a repository. Second, change control: the script should run from a reviewed change with a named approver, because a mistake in an instance-wide 2FA setting affects every user at once. Third, a record of the change, such as the request and response output saved to your change system, plus a read-back of the current settings before and after the run. Confirm the exact endpoints, parameter names and required token scopes in the current GitLab API documentation, because these settings have changed across releases and a script written against an older version can fail silently or set the wrong field.

Test the script against a disposable instance at the same GitLab version as production, and check its effect on a test account that has not yet enrolled. Keep the grace period and the scope of enforcement as explicit inputs so the reviewer sees them, and make the script refuse to run if a required value is missing rather than falling back to a default. Finally, plan how the script is kept current: when you upgrade GitLab, rerun the test and confirm the endpoints still behave as documented before the upgrade reaches production.

Security and operational risks of enforcing 2FA

Mandatory 2FA fails in predictable ways: users get locked out, fallback methods weaken the policy, and automation breaks quietly. Each card below names one risk and the control your team can put in place before the policy takes effect, so enforcement tightens access without stopping delivery.

Users who cannot register a factor

Some users cannot enroll a second factor on day one because they lack a phone, a compatible authenticator app, or a supported security key. If the grace period ends before they can enroll, they land on the setup page with no path forward. Confirm which users lack a device before enforcement, distribute an approved authenticator option, and hold a named administrator who can help people through the setup page during the rollout window.

Weak fallback methods

Once a policy requires 2FA, the enrollment options a user can choose decide how strong the policy really is. A method that accepts a single reusable code, or that users can set up through a shared mailbox or phone, adds little protection. Review which second-factor types your instance accepts, state the approved methods in your access policy, and check enrollments against that list rather than assuming every enrolled method meets the standard.

Administrators outside enforcement

Administrators are the accounts an attacker most wants, yet a rollout that targets only standard users, or that exempts admins for convenience, leaves the most privileged accounts with the weakest sign-in. Decide whether the policy applies to administrators first, enforce it for that group before the wider population, and record any exemption with an owner and an end date. Review the administrator list on a fixed schedule.

Service accounts and bots

Automation that signs in with a human account, such as a deploy user or a sync bot, can break the moment 2FA is enforced because scripts cannot answer a prompt. The API route for automation exists for this case, but it changes the security model, so each use needs review. Inventory every non-human credential, decide whether it uses personal access tokens, project tokens or group tokens, and test each pipeline against a staging instance before the production switch.

Lost WebAuthn keys

A hardware security key that is lost, broken or left at home can lock a user out as effectively as a missing phone. Because keys are often the strongest factor, teams tend to enroll only one, which creates a single point of failure. Require at least two registered factors for privileged accounts where your policy allows it, document a recovery route that verifies identity before any reset, and make sure the reset process is logged.

Failed sign-ins going unwatched

A rollout generates a burst of failed sign-ins, and a credential attack can look the same in the logs as a user who cannot find the setup page. Without monitoring, teams either ignore the noise or revert the policy in a panic. Forward authentication events from your GitLab logs to your central monitoring, set alert thresholds for repeated failures per account, and assign someone to review the spike during the first weeks of enforcement.

Recovering users locked on the 2FA setup page

When enforcement is switched on, a user who has not yet enrolled a two-factor method is redirected to the setup page at sign-in and cannot reach projects until they finish. The usual causes are a lost phone, a replaced authenticator app, a hardware key left at the office, or a user who never saw the grace period notice. Your first step is to decide who handles these requests and what they must check. Treat each request as a potential account takeover, because an attacker who has the password can ask for help in exactly the same way. Confirm the identity of the requester through a channel outside GitLab, such as a call to a number already on file with your identity or HR team, or a manager's confirmation in your ticketing system. Do not accept a reply sent to the account's own email address as proof of identity, since that address may be the thing under attack.

Once identity is confirmed, an administrator can clear the user's registered two-factor methods from the user's profile in the Admin area, which lets the user re-enroll on the next sign-in. Depending on your version, the same action may also be available through the API, so check the exact steps for your release in the GitLab authentication and user documentation before you write a runbook. Where a user should keep access while re-enrolling, confirm whether your policy relies on a grace period or a temporary exception, and record that decision. Avoid disabling the requirement for the whole instance or a group to solve one person's problem, because that change affects everyone enrolled in it.

Record every recovery in a ticket that names the requester, the verification method used, the approving person, the administrator who acted, the time of the change and the reason. Keep the record in the system your auditors already review, not in a personal notebook. Review these tickets regularly, since a cluster of resets for one account or one group can point to phishing, a broken enrollment flow or a badly communicated rollout. Before you enforce anything, confirm with your GitLab version's documentation which recovery options exist, who in your organization is allowed to perform them and how audit events for those actions are retained.

Limits to confirm in your environment

Mandatory 2FA behaves differently depending on how each user signs in, which accounts exist and which version of GitLab you run. The items below are the questions to settle with your own configuration before you set a grace period or switch enforcement on.

Sign-in paths the setting covers

Confirm which authentication paths your instance enforces 2FA on before you rely on it. The GitLab authentication documentation lists LDAP, SAML, generic OAuth 2.0, OmniAuth providers, Kerberos, JWT and smart card sign-in, and these do not all behave the same way. Test each path you use with a non-admin account, and record whether a user can reach the instance through a path that skips the GitLab prompt, such as a Git credential or a token.

Bot and service accounts

Service accounts cannot complete an interactive 2FA prompt. Identify every bot, pipeline and integration account that authenticates with a password or token, and decide whether it is exempt, moved to a token-based credential or scoped to a group that is not enforced. Write the decision down, because an enforcement change applied to a group can lock out automation that runs overnight without anyone watching it.

Behavior across required upgrade stops

Test the 2FA settings on a staging copy after each planned upgrade stop, not only on the target version. GitLab requires upgrades to pass through stops such as 18.2, 18.5, 18.8 and 18.11, and the settings screen and API fields can move between releases. Confirm the grace period, the enforcement scope and any API parameter names against the documentation for each version on your path.

Identity provider MFA overlap

Decide whether GitLab's own second factor is a second prompt on top of the MFA your identity provider already enforces. When SAML or OAuth sign-in handles the second factor at the provider, users may be asked twice or may see unexpected prompts. Ask your identity team which factors Entra ID, Okta or Google enforces for the GitLab application, then agree which layer owns the requirement so the two do not conflict.

WebAuthn hardware in your fleet

Inventory the hardware security keys and platform authenticators your users actually hold before you choose WebAuthn as a required option. Browser and operating system support varies, and some managed devices restrict which keys can be registered. Confirm that each key type works in the browsers your staff use, and keep a time-based one-time password option available for users whose hardware is not supported.

Recovery codes and locked accounts

Verify how users recover access when they lose a device or never finished setup. Test that a user who is locked on the setup page can complete registration, that an administrator can reset a factor, and that recovery codes are stored by each user in a place your policy allows. Confirm the procedure with your service desk before enforcement, because the first lockouts usually arrive on the same day as the change.

Questions teams ask before enforcing 2FA in GitLab

What does it cost to enforce 2FA in self-managed GitLab?

The software cost depends on your tier. GitLab's pricing page lists Free at 0 US dollars, Premium at 29 US dollars per user per month billed annually, and Ultimate as custom priced, with all three tiers available for self-managed installations. Enforcing 2FA is a configuration change, so most of the engagement cost is labor: planning the policy, testing enrollment, writing user guidance, staffing the helpdesk and checking the result. Planning and rollout work is mostly one-time, while per-user subscription fees recur if you are on a paid tier. The main cost drivers are user count, the number of groups with different rules, whether an identity provider already handles sign-in, and how much helpdesk capacity you have. Ask any partner for a quote that lists each of these as a separate line, with the scope agreed in writing.

How long does a 2FA rollout take in GitLab?

The pace is set by your user population, your grace period and your change process, not by the setting itself. Timing depends on how many users, groups and time zones are involved, how long users get to enroll before enforcement applies, and how many approvals your change process requires. A common sequence is to enforce for administrators first, pilot with one group, then extend to the rest of the instance, with communication and helpdesk readiness set before each step. The materials behind this page do not give a duration, so ask your internal lead or a partner to produce a dated plan from your own inventory of users and groups. Avoid holidays, audit windows and your own upgrade windows. GitLab ships patch releases twice a month, so schedule 2FA changes on their own calendar rather than stacking them onto upgrade work.

What must our team provide before a 2FA rollout starts?

Before work starts, your team needs to provide administrator access, a written identity policy and a communication plan. Administrator access should include an account that can change instance-wide sign-in settings and group settings, plus a way to reach the server for recovery if a change locks out the wrong population. The identity policy decides which authentication methods are allowed, which groups or roles are covered, how long the grace period runs and how exceptions are approved. The communication plan covers announcements, the enrollment steps users will see, the support channel and the escalation path. You should also supply an inventory of service and automation accounts, a named approver for each stage and a pilot group willing to test early. Without these inputs, any scope agreed in writing will rest on assumptions that surface during the rollout.

Can our own team enforce 2FA in GitLab without a partner?

Yes, most teams can enforce 2FA with their own administrators, because the core work is configuration and communication. The hard parts are rarely the setting itself. They are deciding the policy, testing edge cases such as service accounts and users without a supported device, and handling the first wave of lockouts. A team that already operates a GitLab instance and has a helpdesk runbook can usually do this internally. A partner adds value when staff are stretched, when the rollout spans many groups or identity sources, or when you need documented evidence for an assessment. DeployOpen plans, implements and documents self-hosted platforms inside your own infrastructure, works on fixed-scope engagements with scope, deliverables and timelines agreed in writing first, and offers retainers for ongoing support. Either way, name who owns the helpdesk queue during the grace period.

How do grace periods affect helpdesk load?

A grace period lets users enroll in 2FA before enforcement blocks their normal sign-in, so the length and timing of that window shape when support tickets arrive. Most of the load lands at the deadline, when users who have not enrolled are sent to the setup page and some discover they have no working device. Stagger deadlines by group so that one support team is not handling the whole organization at once. Pre-enroll administrators and service owners, send reminders before the deadline and publish a short guide for each supported method. Plan for the users who lose a phone or security key, since recovery requires a defined identity check and an administrator who knows the steps. Ask your helpdesk to estimate volume from the enrollment report of the pilot group, and treat that estimate as your own planning input rather than a fixed figure.

Does enabling 2FA in GitLab satisfy a compliance control?

No. Enabling 2FA is one input to a control, and it rarely satisfies a control by itself. Frameworks such as NIST SP 800-53 describe identification and authentication requirements in terms of control families and enhancements, so map the setting to the specific control IDs your assessor uses, then document how it meets each one. The evidence an assessor will ask for usually includes the written policy, the configuration in effect, enrollment reports, exception records with approvals and the procedure for recovering locked accounts. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so confirm early which control IDs and evidence formats your auditor expects.

Which 2FA methods should we allow, TOTP or WebAuthn?

Allow the methods your users can actually use, and require a recovery path for each. Time-based one-time passwords work with widely available authenticator apps and need no hardware purchase, but they depend on a phone and can be phished by a user who enters a code on a fake page. WebAuthn works with security keys and platform authenticators and resists phishing better, but it needs hardware budget, a distribution process and a plan for lost keys. Many teams enable both, encourage WebAuthn for administrators and privileged roles, and require at least two enrolled methods for those accounts. Confirm the exact options your GitLab version offers in its authentication documentation before writing the policy, and test each method with a pilot group on a non-production instance first.

How do API settings and automation accounts fit into 2FA enforcement?

Automation accounts cannot complete an interactive 2FA prompt, so enforcement must account for them before it goes live. Inventory every service account, bot, CI integration and provisioning script that authenticates to the instance, and decide for each whether it needs a token, a dedicated non-human account or an exception. Use the API settings for 2FA to configure the instance from scripts, so the policy is reproducible across environments and recorded in version control. Test each automation path in a staging instance before enforcement, because a broken pipeline is often the first visible symptom of an incomplete inventory. Check how personal and project access tokens behave under your chosen enforcement mode in the documentation for your version, and confirm the expected behavior with a test account rather than assuming it.

How DeployOpen scopes and delivers 2FA enforcement

DeployOpen scopes a 2FA enforcement rollout as a fixed-scope engagement, with the scope, deliverables and timeline agreed in writing before any change is made to your GitLab instance. The written scope names which enforcement mode applies (instance-wide, administrators only, or specific groups), which users and groups are in and out, how grace periods are set, which second factors are accepted (TOTP, WebAuthn or both), and how API-driven automation will be handled. Each of these is a decision with consequences for users, so the scope document records who made it and why. Your team stays the owner of the instance, and the work happens inside your own infrastructure, with your administrators holding the access they need for the changes.

The enforcement design covers the settings themselves and the order in which they take effect. DeployOpen reviews the instance's sign-in path, including any SAML or LDAP sign-in that bypasses or interacts with GitLab's own two-factor prompt, so that enforcement does not create gaps or unexpected lockouts. The design also sets out the procedure for users who have not yet enrolled, including how they recover access from the setup page, and who in your organization approves exceptions. A pilot group, usually a small set of administrators or one engineering group, runs through enrollment before the wider rollout. DeployOpen also drafts the user communication and support notes your help desk needs, and tests the pilot with your staff before the change reaches everyone.

Verification happens on your instance, and the results are delivered as evidence you keep. Typical checks confirm that enforcement applies to the intended population, that enrollment completes for TOTP and WebAuthn, that API tokens used by automation continue to work under the agreed rules, and that locked users can recover through the documented path. DeployOpen prepares these controls, configuration records and test results as material for your internal reviews and for external assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations. Ongoing support, such as handling new users, changing exceptions or reviewing settings after GitLab upgrades, is available as a retainer. Ask for the retainer terms in the same written quote as the fixed-scope work.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.