auth0.md 2.92 KB
Newer Older
1 2 3 4 5
# Auth0 OmniAuth Provider

To enable the Auth0 OmniAuth provider, you must create an Auth0 account, and an
application.

Evan Read's avatar
Evan Read committed
6
1. Sign in to the [Auth0 Console](https://auth0.com/auth/login). If you need to
7
   create an account, you can do so at the same link.
8 9 10 11 12 13

1. Select "New App/API".

1. Provide the Application Name ('GitLab' works fine).

1. Once created, you should see the Quick Start options. Disregard them and
14
   select 'Settings' above the Quick Start options.
15 16

1. At the top of the Settings screen, you should see your Domain, Client ID and
17 18
   Client Secret. Take note of these as you'll need to put them in the
   configuration file. For example:
19 20 21 22 23
    - Domain: `test1234.auth0.com`
    - Client ID: `t6X8L2465bNePWLOvt9yi41i`
    - Client Secret: `KbveM3nqfjwCbrhaUy_gDu2dss8TIlHIdzlyf33pB7dEK5u_NyQdp65O_o02hXs2`

1. Fill in the Allowed Callback URLs:
24 25
    - `http://YOUR_GITLAB_URL/users/auth/auth0/callback` (or)
    - `https://YOUR_GITLAB_URL/users/auth/auth0/callback`
26 27

1. Fill in the Allowed Origins (CORS):
28 29
    - `http://YOUR_GITLAB_URL` (or)
    - `https://YOUR_GITLAB_URL`
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

1. On your GitLab server, open the configuration file.

    For omnibus package:

    ```sh
      sudo editor /etc/gitlab/gitlab.rb
    ```

    For installations from source:

    ```sh
      cd /home/git/gitlab
      sudo -u git -H editor config/gitlab.yml
    ```

1. See [Initial OmniAuth Configuration](omniauth.md#initial-omniauth-configuration)
47
   for initial settings.
48 49 50 51 52 53 54 55 56

1. Add the provider configuration:

    For omnibus package:

    ```ruby
      gitlab_rails['omniauth_providers'] = [
        {
          "name" => "auth0",
Reb's avatar
Reb committed
57
          "args" => { client_id: 'YOUR_AUTH0_CLIENT_ID',
58
                      client_secret: 'YOUR_AUTH0_CLIENT_SECRET',
59 60
                      domain: 'YOUR_AUTH0_DOMAIN',
                      scope: 'openid profile email'
61 62 63 64 65 66 67 68 69 70 71 72
                    }
        }
      ]
    ```

    For installations from source:

    ```yaml
      - { name: 'auth0',
          args: {
            client_id: 'YOUR_AUTH0_CLIENT_ID',
            client_secret: 'YOUR_AUTH0_CLIENT_SECRET',
73 74
            domain: 'YOUR_AUTH0_DOMAIN',
            scope: 'openid profile email' }
75 76 77 78
        }
    ```

1. Change `YOUR_AUTH0_CLIENT_ID` to the client ID from the Auth0 Console page
79
   from step 5.
80 81

1. Change `YOUR_AUTH0_CLIENT_SECRET` to the client secret from the Auth0 Console
82
   page from step 5.
83

84 85
1.  [Reconfigure][] or [restart GitLab][] for the changes to take effect if you
    installed GitLab via Omnibus or from source respectively.
86 87 88 89 90

On the sign in page there should now be an Auth0 icon below the regular sign in
form. Click the icon to begin the authentication process. Auth0 will ask the
user to sign in and authorize the GitLab application. If everything goes well
the user will be returned to GitLab and will be signed in.
91 92

[reconfigure]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
93
[restart GitLab]: ../administration/restart_gitlab.md#installations-from-source