Use Facebook as an OAuth 2.0 authentication provider (FREE ALL)
You can use the Facebook OmniAuth provider to authenticate users with their Facebook account.
To enable the Facebook OmniAuth provider, you must:
- Register your application with Facebook. Facebook generates an app ID and a secret key for you to use.
- Configure the GitLab server.
Register your application with Facebook
-
Sign in to your Facebook developer account.
-
Go to My Apps > Create App, then complete the following steps:
-
In the upper-right corner, select Skip Quick Start.
-
From the menu on the left, select Settings, then complete the following:
-
From the menu on the left, select Status & Review, then complete the following:
-
Change the switch on the right from No to Yes.
-
When prompted to make the app public, select Confirm.
-
-
From the menu on the left, select Dashboard, then complete the following:
Configure the GitLab server
-
On your GitLab server, open the configuration file:
::Tabs
:::TabTitle Linux package installations
sudo editor /etc/gitlab/gitlab.rb
:::TabTitle Self-compiled installations
cd /home/git/gitlab sudo -u git -H editor config/gitlab.yml
::EndTabs
-
Configure the common settings to add
facebook
as a single sign-on provider. This enables Just-In-Time account provisioning for users who do not have an existing GitLab account. -
Add the provider configuration:
::Tabs
:::TabTitle Linux package installations
gitlab_rails['omniauth_providers'] = [ { name: "facebook", # label: "Provider name", # optional label for login button, defaults to "Facebook" app_id: "YOUR_APP_ID", app_secret: "YOUR_APP_SECRET" } ]
:::TabTitle Self-compiled installations
- { name: 'facebook', # label: 'Provider name', # optional label for login button, defaults to "Facebook" app_id: 'YOUR_APP_ID', app_secret: 'YOUR_APP_SECRET' }
::EndTabs
-
In the provide configuration, paste the following values:
-
YOUR_APP_ID
: The App ID you copied in the previous step. -
YOUR_APP_SECRET
: The App Secret you copied in the previous step.
-
-
Save the configuration file.
-
For the changes to take effect:
- If you installed using the Linux package, reconfigure GitLab.
- If you self-compiled your installation, restart GitLab.
On the sign in page, a Facebook icon should now appear below the sign-in fields. The user can select the icon to sign in.