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

/doc/integration/oauth_provider.md

https://gitlab.com/artofhuman/gitlab-ce
Markdown | 89 lines | 58 code | 31 blank | 0 comment | 0 complexity | 82d9944dbcae11b644dd138b75b0d18d MD5 | raw file
  1. # GitLab as OAuth2 authentication service provider
  2. This document is about using GitLab as an OAuth authentication service provider
  3. to sign in to other services.
  4. If you want to use:
  5. - Other OAuth authentication service providers to sign in to
  6. GitLab, see the [OAuth2 client documentation](omniauth.md).
  7. - The related API, see [Applications API](../api/applications.md).
  8. ## Introduction to OAuth
  9. [OAuth] provides to client applications a 'secure delegated access' to server
  10. resources on behalf of a resource owner. In fact, OAuth allows an authorization
  11. server to issue access tokens to third-party clients with the approval of the
  12. resource owner, or the end-user.
  13. OAuth is mostly used as a Single Sign-On service (SSO), but you can find a
  14. lot of different uses for this functionality. For example, you can allow users
  15. to sign in to your application with their GitLab.com account, or GitLab.com
  16. can be used for authentication to your GitLab instance
  17. (see [GitLab OmniAuth](gitlab.md)).
  18. The 'GitLab Importer' feature is also using the OAuth protocol to give access
  19. to repositories without sharing user credentials to your GitLab.com account.
  20. ---
  21. GitLab supports two ways of adding a new OAuth2 application to an instance. You
  22. can either add an application as a regular user or add it in the admin area.
  23. What this means is that GitLab can actually have instance-wide and a user-wide
  24. applications. There is no difference between them except for the different
  25. permission levels they are set (user/admin). The default callback URL is
  26. `http://your-gitlab.example.com/users/auth/gitlab/callback`
  27. ## Adding an application through the profile
  28. In order to add a new application via your profile, navigate to
  29. **Profile Settings > Applications** and select **New Application**.
  30. ![New OAuth application](img/oauth_provider_user_wide_applications.png)
  31. ---
  32. In the application form, enter a **Name** (arbitrary), and make sure to set up
  33. correctly the **Redirect URI** which is the URL where users will be sent after
  34. they authorize with GitLab.
  35. ![New OAuth application form](img/oauth_provider_application_form.png)
  36. ---
  37. When you hit **Submit** you will be provided with the application ID and
  38. the application secret which you can then use with your application that
  39. connects to GitLab.
  40. ![OAuth application ID and secret](img/oauth_provider_application_id_secret.png)
  41. ---
  42. ## OAuth applications in the admin area
  43. To create an application that does not belong to a certain user, you can create
  44. it from the admin area.
  45. ![OAuth admin_applications](img/oauth_provider_admin_application.png)
  46. You're also able to mark an application as _trusted_ when creating it through the admin area. By doing that,
  47. the user authorization step is automatically skipped for this application.
  48. ---
  49. ## Authorized applications
  50. Every application you authorized to use your GitLab credentials will be shown
  51. in the **Authorized applications** section under **Profile Settings > Applications**.
  52. ![Authorized_applications](img/oauth_provider_authorized_application.png)
  53. ---
  54. GitLab's OAuth applications support scopes, which allow various actions that any given
  55. application can perform such as `read_user` and `api`. There are many more scopes
  56. available.
  57. At any time you can revoke any access by just clicking **Revoke**.
  58. [oauth]: http://oauth.net/2/ "OAuth website"