PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/integration/azure.md

https://gitlab.com/523/gitlab-ce
Markdown | 149 lines | 111 code | 38 blank | 0 comment | 0 complexity | 3c2fa88c9dd47db15830bd5444eb7862 MD5 | raw file
  1. ---
  2. stage: Manage
  3. group: Authentication and Authorization
  4. info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
  5. ---
  6. # Use Microsoft Azure as an authentication provider **(FREE SELF)**
  7. You can enable the Microsoft Azure OAuth 2.0 OmniAuth provider and sign in to
  8. GitLab with your Microsoft Azure credentials. You can configure the provider that uses
  9. [the earlier Azure Active Directory v1.0 endpoint](https://docs.microsoft.com/en-us/azure/active-directory/azuread-dev/v1-protocols-oauth-code),
  10. or the provider that uses the v2.0 endpoint.
  11. NOTE:
  12. For new projects, Microsoft suggests you use the
  13. [OpenID Connect protocol](../administration/auth/oidc.md#microsoft-azure),
  14. which uses the Microsoft identity platform (v2.0) endpoint.
  15. ## Register an Azure application
  16. To enable the Microsoft Azure OAuth 2.0 OmniAuth provider, you must register
  17. an Azure application and get a client ID and secret key.
  18. 1. Sign in to the [Azure portal](https://portal.azure.com).
  19. 1. If you have multiple Azure Active Directory tenants, switch to the desired tenant.
  20. 1. [Register an application](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app)
  21. and provide the following information:
  22. - The redirect URI, which requires the URL of the Azure OAuth callback of your GitLab
  23. installation. For example:
  24. - For the v1.0 endpoint: `https://gitlab.example.com/users/auth/azure_oauth2/callback`.
  25. - For the v2.0 endpoint: `https://gitlab.example.com/users/auth/azure_activedirectory_v2/callback`.
  26. - The application type, which must be set to **Web**.
  27. 1. Save the client ID and client secret. The client secret is only
  28. displayed once.
  29. If required, you can [create a new application secret](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret).
  30. `client ID` and `client secret` are terms associated with OAuth 2.0.
  31. In some Microsoft documentation, the terms are named `Application ID` and
  32. `Application Secret`.
  33. ## Add API permissions (scopes)
  34. If you're using the v2.0 endpoint, after you create the application, [configure it to expose a web API](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-expose-web-apis).
  35. Add the following delegated permissions under the Microsoft Graph API:
  36. - `email`
  37. - `openid`
  38. - `profile`
  39. Alternatively, add the `User.Read.All` application permission.
  40. ## Enable Microsoft OAuth in GitLab
  41. 1. On your GitLab server, open the configuration file.
  42. - **For Omnibus installations**
  43. ```shell
  44. sudo editor /etc/gitlab/gitlab.rb
  45. ```
  46. - **For installations from source**
  47. ```shell
  48. cd /home/git/gitlab
  49. sudo -u git -H editor config/gitlab.yml
  50. ```
  51. 1. [Configure the initial settings](omniauth.md#configure-initial-settings).
  52. 1. Add the provider configuration. Replace `CLIENT ID`, `CLIENT SECRET`, and `TENANT ID`
  53. with the values you got when you registered the Azure application.
  54. - **For Omnibus installations**
  55. For the v1.0 endpoint:
  56. ```ruby
  57. gitlab_rails['omniauth_providers'] = [
  58. {
  59. name: "azure_oauth2",
  60. # label: "Provider name", # optional label for login button, defaults to "Azure AD"
  61. args: {
  62. client_id: "CLIENT ID",
  63. client_secret: "CLIENT SECRET",
  64. tenant_id: "TENANT ID",
  65. }
  66. }
  67. ]
  68. ```
  69. For the v2.0 endpoint:
  70. ```ruby
  71. gitlab_rails['omniauth_providers'] = [
  72. {
  73. "name" => "azure_activedirectory_v2",
  74. "label" => "Provider name", # optional label for login button, defaults to "Azure AD v2"
  75. "args" => {
  76. "client_id" => "CLIENT ID",
  77. "client_secret" => "CLIENT SECRET",
  78. "tenant_id" => "TENANT ID",
  79. }
  80. }
  81. ]
  82. ```
  83. - **For installations from source**
  84. For the v1.0 endpoint:
  85. ```yaml
  86. - { name: 'azure_oauth2',
  87. # label: 'Provider name', # optional label for login button, defaults to "Azure AD"
  88. args: { client_id: 'CLIENT ID',
  89. client_secret: 'CLIENT SECRET',
  90. tenant_id: 'TENANT ID' } }
  91. ```
  92. For the v2.0 endpoint:
  93. ```yaml
  94. - { name: 'azure_activedirectory_v2',
  95. label: 'Provider name', # optional label for login button, defaults to "Azure AD v2"
  96. args: { client_id: "CLIENT ID",
  97. client_secret: "CLIENT SECRET",
  98. tenant_id: "TENANT ID" } }
  99. ```
  100. You can optionally add the following parameters:
  101. - `base_azure_url` for different locales. For example, `base_azure_url: "https://login.microsoftonline.de"`.
  102. - `scope`, which you add to `args`. The default is `openid profile email`.
  103. 1. Save the configuration file.
  104. 1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure)
  105. if you installed using Omnibus, or [restart GitLab](../administration/restart_gitlab.md#installations-from-source)
  106. if you installed from source.
  107. 1. Refresh the GitLab sign-in page. A Microsoft icon should display below the
  108. sign-in form.
  109. 1. Select the icon. Sign in to Microsoft and authorize the GitLab application.
  110. Read [Enable OmniAuth for an existing user](omniauth.md#enable-omniauth-for-an-existing-user)
  111. for information on how existing GitLab users can connect to their new Azure AD accounts.