Sha256: f813c4eb7afd80312baae56c1dab34b6bac68f43cc934c971fc9b7f1dc70047c

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require 'multi_json'
require 'omniauth/strategies/oauth2'

module OmniAuth
  module Strategies
    class ShuttlerockOauth2 < OmniAuth::Strategies::OAuth2
      option :name, 'shuttlerock_oauth2'

      option :client_options, {
        site:              ENV['SHUTTLEROCK_OAUTH2_SITE'] || 'https://login.shuttlerock.com',
        request_token_url: '/oauth/request_token',
        authorize_url:     '/oauth/authorize',
        token_url:         '/oauth/token',
      }

      uid { raw_info['uid'] }

      info do
        {
          email: raw_info['email'],
          roles: raw_info['roles'],
        }
      end

      def raw_info
        @raw_info ||= MultiJson.decode(access_token.get('/api/v1/me').body)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-shuttlerock-oauth2-0.0.2 lib/omniauth/strategies/shuttlerock_oauth2.rb