Sha256: 6858b4fe50c92fd2753ecd3c35cf13b9fd4d27f6804fa3c8d7e6349d089c81d1

Contents?: true

Size: 771 Bytes

Versions: 3

Compression:

Stored size: 771 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class GitLab < OmniAuth::Strategies::OAuth2
      option :client_options, site: 'https://gitlab.com/api/v4'

      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('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

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-gitlab-3.0.0 lib/omniauth/strategies/gitlab.rb
omniauth-gitlab-2.0.0 lib/omniauth/strategies/gitlab.rb
omniauth-gitlab-1.0.3 lib/omniauth/strategies/gitlab.rb