Sha256: 5b757de10891ef5dd75c104929bbc4ac34ff0c19ac1662a594f06f426eb73ef1

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Idnet < OmniAuth::Strategies::OAuth2

      option :name, "idnet"

      option :fields, OmniAuth::Idnet::DEFAULT

      option :client_options, {
        :site => "https://www.id.net",
        :ssl => { verify: true }
      }

      option :authorize_options, [:scope, :display]

      uid { raw_info['pid'] }

      info do
        options.fields.inject({}) do |hash, field|
          hash[field] = raw_info[field.to_s]
          hash
        end
      end

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

      def authorize_params
        super.tap do |params|
          if Enumerable === request.params['prefill']
            request.params['prefill'].each do |key, value|
              params.merge!(("prefill[" + key.to_s + "]").to_sym => value)
            end
          end
          if Enumerable === request.params['meta']
            request.params['meta'].each do |key, value|
              params.merge!(("meta[" + key.to_s + "]").to_sym => value)
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-idnet-0.0.10 lib/omniauth/strategies/idnet.rb
omniauth-idnet-0.0.9 lib/omniauth/strategies/idnet.rb