PageRenderTime 25ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/integration/google.md

https://gitlab.com/rymai/gitlab
Markdown | 120 lines | 93 code | 27 blank | 0 comment | 0 complexity | 5675e5d5275f539b452e024f9d6b88d0 MD5 | raw file
  1. # Google OAuth2 OmniAuth Provider
  2. To enable the Google OAuth2 OmniAuth provider you must register your application
  3. with Google. Google will generate a client ID and secret key for you to use.
  4. ## Enabling Google OAuth
  5. In Google's side:
  6. 1. Navigate to the [cloud resource manager](https://console.cloud.google.com/cloud-resource-manager) page
  7. 1. Select **Create Project**
  8. 1. Provide the project information:
  9. - **Project name** - "GitLab" works just fine here.
  10. - **Project ID** - Must be unique to all Google Developer registered applications.
  11. Google provides a randomly generated Project ID by default. You can use
  12. the randomly generated ID or choose a new one.
  13. 1. Refresh the page and you should see your new project in the list
  14. 1. Go to the [Google API Console](https://console.developers.google.com/apis/dashboard)
  15. 1. Select the previously created project in the upper left corner
  16. 1. Select **Credentials** from the sidebar
  17. 1. Select **OAuth consent screen** and fill the form with the required information
  18. 1. In the **Credentials** tab, select **Create credentials > OAuth client ID**
  19. 1. Fill in the required information
  20. - **Application type** - Choose "Web Application"
  21. - **Name** - Use the default one or provide your own
  22. - **Authorized JavaScript origins** -This isn't really used by GitLab but go
  23. ahead and put `https://gitlab.example.com`
  24. - **Authorized redirect URIs** - Enter your domain name followed by the
  25. callback URIs one at a time:
  26. ```
  27. https://gitlab.example.com/users/auth/google_oauth2/callback
  28. https://gitlab.example.com/-/google_api/auth/callback
  29. ```
  30. 1. You should now be able to see a Client ID and Client secret. Note them down
  31. or keep this page open as you will need them later.
  32. 1. To enable projects to access [Google Kubernetes Engine](../user/project/clusters/index.md), you must also
  33. enable these APIs:
  34. - Google Kubernetes Engine API
  35. - Cloud Resource Manager API
  36. - Cloud Billing API
  37. To do so you need to:
  38. 1. Go to the [Google API Console](https://console.developers.google.com/apis/dashboard).
  39. 1. Click on **ENABLE APIS AND SERVICES** button at the top of the page.
  40. 1. Find each of the above APIs. On the page for the API, press the **ENABLE** button.
  41. It may take a few minutes for the API to be fully functional.
  42. On your GitLab server:
  43. 1. Open the configuration file.
  44. For Omnibus GitLab:
  45. ```shell
  46. sudo editor /etc/gitlab/gitlab.rb
  47. ```
  48. For installations from source:
  49. ```shell
  50. cd /home/git/gitlab
  51. sudo -u git -H editor config/gitlab.yml
  52. ```
  53. 1. See [Initial OmniAuth Configuration](omniauth.md#initial-omniauth-configuration) for initial settings.
  54. 1. Add the provider configuration:
  55. For Omnibus GitLab:
  56. ```ruby
  57. gitlab_rails['omniauth_providers'] = [
  58. {
  59. "name" => "google_oauth2",
  60. "app_id" => "YOUR_APP_ID",
  61. "app_secret" => "YOUR_APP_SECRET",
  62. "args" => { "access_type" => "offline", "approval_prompt" => '' }
  63. }
  64. ]
  65. ```
  66. For installations from source:
  67. ```yaml
  68. - { name: 'google_oauth2', app_id: 'YOUR_APP_ID',
  69. app_secret: 'YOUR_APP_SECRET',
  70. args: { access_type: 'offline', approval_prompt: '' } }
  71. ```
  72. 1. Change `YOUR_APP_ID` to the client ID from the Google Developer page
  73. 1. Similarly, change `YOUR_APP_SECRET` to the client secret
  74. 1. Make sure that you configure GitLab to use an FQDN as Google will not accept
  75. raw IP addresses.
  76. For Omnibus packages:
  77. ```ruby
  78. external_url 'https://gitlab.example.com'
  79. ```
  80. For installations from source:
  81. ```yaml
  82. gitlab:
  83. host: https://gitlab.example.com
  84. ```
  85. 1. Save the configuration file.
  86. 1. [Reconfigure][] or [restart GitLab][] for the changes to take effect if you
  87. installed GitLab via Omnibus or from source respectively.
  88. On the sign in page there should now be a Google icon below the regular sign in
  89. form. Click the icon to begin the authentication process. Google will ask the
  90. user to sign in and authorize the GitLab application. If everything goes well
  91. the user will be returned to GitLab and will be signed in.
  92. [reconfigure]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
  93. [restart GitLab]: ../administration/restart_gitlab.md#installations-from-source