Sha256: 8565cba7ddbace07ffdd9b4930e7a6769aba6992fa3f847dfcda5b9a02d8245a

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class GitLab < OmniAuth::Strategies::OAuth2

      option :client_options, {
          site: 'https://gitlab.com',
          authorize_url: '/oauth/authorize',
          token_url: '/oauth/token'
      }

      option :redirect_url

      uid { raw_info['id'].to_s }

      info do
        {
            name:     raw_info['name'],
            username: raw_info['username'],
            email:    raw_info['email'],
            image:    raw_info['avatar_url']
        }
      end

      extra do
        { raw_info: raw_info }
      end

      def raw_info
        @raw_info ||= access_token.get('/api/v3/user').parsed
      end

      private

      def callback_url
        options.redirect_url || (full_host + script_name + callback_path)
      end
    end
  end
end


OmniAuth.config.add_camelization 'gitlab', 'GitLab'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-gitlab-1.0.2 lib/omniauth/strategies/gitlab.rb