PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/omniauth/strategies/gitlab.rb

https://gitlab.com/axil/omniauth-gitlab
Ruby | 30 lines | 24 code | 6 blank | 0 comment | 0 complexity | 97a2e0002d7ff22689963353aa90ddeb MD5 | raw file
  1. require 'omniauth-oauth2'
  2. module OmniAuth
  3. module Strategies
  4. class GitLab < OmniAuth::Strategies::OAuth2
  5. option :name, 'gitlab'
  6. option :client_options, {
  7. site: 'https://gitlab.com',
  8. authorize_url: '/oauth/authorize/',
  9. token_url: '/oauth/token/'
  10. }
  11. uid { raw_info["id"] }
  12. info do
  13. {
  14. email: raw_info["email"],
  15. username: raw_info["username"],
  16. name: raw_info["name"]
  17. }
  18. end
  19. def raw_info
  20. @raw_info ||= access_token.get('/api/v3/user').parsed
  21. end
  22. end # GitLab
  23. end # Strategies
  24. end # OmniAuth