PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/integration/oauth_provider.md

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