PageRenderTime 27ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/integration/bitbucket.md

https://gitlab.com/randaalex/gitlab-ce
Markdown | 127 lines | 100 code | 27 blank | 0 comment | 0 complexity | 938f4f76238f37d3eb50b6638db7bcfb 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. # Integrate your GitLab server with Bitbucket Cloud **(FREE SELF)**
  7. You can set up Bitbucket.org as an OAuth 2.0 provider to use your Bitbucket.org
  8. account credentials to sign in to GitLab. You can also import your projects from
  9. Bitbucket.org.
  10. - To use Bitbucket.org as an OmniAuth provider, follow the
  11. [Bitbucket OmniAuth provider](#bitbucket-omniauth-provider) section.
  12. - To import projects from Bitbucket, follow both the
  13. [Bitbucket OmniAuth provider](#bitbucket-omniauth-provider) and
  14. [Bitbucket project import](#bitbucket-project-import) sections.
  15. ## Bitbucket OmniAuth provider
  16. To enable the Bitbucket OmniAuth provider you must register your application
  17. with Bitbucket.org. Bitbucket generates an application ID and secret key for
  18. you to use.
  19. WARNING:
  20. To help prevent an [OAuth 2 covert redirect](https://oauth.net/advisories/2014-1-covert-redirect/)
  21. vulnerability in which users' GitLab accounts could be compromised, append `/users/auth`
  22. to the end of the Bitbucket authorization callback URL.
  23. 1. Sign in to [Bitbucket.org](https://bitbucket.org).
  24. 1. Navigate to your individual user settings (**Bitbucket settings**) or a team's
  25. settings (**Manage team**), depending on how you want the application registered.
  26. It does not matter if the application is registered as an individual or a
  27. team, that is entirely up to you.
  28. 1. In the left menu under **Access Management**, select **OAuth**.
  29. 1. Select **Add consumer**.
  30. 1. Provide the required details:
  31. - **Name:** This can be anything. Consider something like `<Organization>'s GitLab`
  32. or `<Your Name>'s GitLab` or something else descriptive.
  33. - **Application description:** Optional. Fill this in if you wish.
  34. - **Callback URL:** (Required in GitLab versions 8.15 and greater)
  35. The URL to your GitLab installation, such as
  36. `https://gitlab.example.com/users/auth`.
  37. Leaving this field empty
  38. [results in an `Invalid redirect_uri` message](https://confluence.atlassian.com/bitbucket/oauth-faq-338365710.html).
  39. - **URL:** The URL to your GitLab installation, such as `https://gitlab.example.com`.
  40. 1. Grant at least the following permissions:
  41. ```plaintext
  42. Account: Email, Read
  43. Projects: Read
  44. Repositories: Read
  45. Pull Requests: Read
  46. Issues: Read
  47. Wiki: Read and Write
  48. ```
  49. ![Bitbucket OAuth settings page](img/bitbucket_oauth_settings_page.png)
  50. 1. Select **Save**.
  51. 1. Select your newly created OAuth consumer, and you should now see a **Key** and
  52. **Secret** in the list of OAuth consumers. Keep this page open as you continue
  53. the configuration.
  54. ![Bitbucket OAuth key](img/bitbucket_oauth_keys.png)
  55. 1. On your GitLab server, open the configuration file:
  56. ```shell
  57. # For Omnibus packages
  58. sudo editor /etc/gitlab/gitlab.rb
  59. # For installations from source
  60. sudo -u git -H editor /home/git/gitlab/config/gitlab.yml
  61. ```
  62. 1. Add the Bitbucket provider configuration:
  63. For Omnibus packages:
  64. ```ruby
  65. gitlab_rails['omniauth_providers'] = [
  66. {
  67. name: "bitbucket",
  68. # label: "Provider name", # optional label for login button, defaults to "Bitbucket"
  69. app_id: "BITBUCKET_APP_KEY",
  70. app_secret: "BITBUCKET_APP_SECRET",
  71. url: "https://bitbucket.org/"
  72. }
  73. ]
  74. ```
  75. For installations from source:
  76. ```yaml
  77. omniauth:
  78. enabled: true
  79. providers:
  80. - { name: 'bitbucket',
  81. # label: 'Provider name', # optional label for login button, defaults to "Bitbucket"
  82. app_id: 'BITBUCKET_APP_KEY',
  83. app_secret: 'BITBUCKET_APP_SECRET',
  84. url: 'https://bitbucket.org/' }
  85. ```
  86. Where `BITBUCKET_APP_KEY` is the Key and `BITBUCKET_APP_SECRET` the Secret
  87. from the Bitbucket application page.
  88. 1. Save the configuration file.
  89. 1. For the changes to take effect, [reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure)
  90. if you installed using Omnibus GitLab, or [restart](../administration/restart_gitlab.md#installations-from-source)
  91. if you installed from source.
  92. On the sign-in page there should now be a Bitbucket icon below the regular
  93. sign-in form. Select the icon to begin the authentication process. Bitbucket asks
  94. the user to sign in and authorize the GitLab application. If successful, the user
  95. is returned to GitLab and signed in.
  96. ## Bitbucket project import
  97. After the above configuration is set up, you can use Bitbucket to sign into
  98. GitLab and [start importing your projects](../user/project/import/bitbucket.md).
  99. If you want to import projects from Bitbucket, but don't want to enable signing in,
  100. you can [disable Sign-Ins in the Admin Area](omniauth.md#enable-or-disable-sign-in-with-an-omniauth-provider-without-disabling-import-sources).