class OmniAuth::Strategies::NaranyaId
Public Instance Methods
configure_sdk!()
click to toggle source
Configures the SDK’s key + secret using the strategy’s configured key and secret
# File lib/omniauth/strategies/naranya_id.rb, line 94 def configure_sdk! ::NaranyaId.configure do |config| %w(consumer_key consumer_secret debug_oauth).each do |method| config.send "#{method}=".to_sym, options.send(method.to_sym) end end end
consumer()
click to toggle source
Override para habilitar/deshabilitar el output de debuggeo de HTTP:
# File lib/omniauth/strategies/naranya_id.rb, line 17 def consumer consumer = ::OAuth::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options) consumer.http.open_timeout = options.open_timeout if options.open_timeout consumer.http.read_timeout = options.read_timeout if options.read_timeout # Se habilita el output sólo si en las opciones debug_oauth es true: consumer.http.set_debug_output($stderr) if options.debug_oauth consumer end
consumer_key_and_secret_present?()
click to toggle source
Indicates whether the consumer key and secret where configured in the strategy initializer
# File lib/omniauth/strategies/naranya_id.rb, line 89 def consumer_key_and_secret_present? options.consumer_key && options.consumer_secret end
raw_info()
click to toggle source
Provee la informacion consultada del usuario vía el API de Naranya ID ()
# File lib/omniauth/strategies/naranya_id.rb, line 70 def raw_info @raw_info ||= begin configure_sdk! if sdk_key_or_secret_missing? and consumer_key_and_secret_present? u = ::NaranyaId::User.find_one( token: access_token.params[:oauth_token], secret: access_token.params[:oauth_token_secret] ) u.attributes.with_indifferent_access rescue ::Errno::ETIMEDOUT raise ::Timeout::Error end end
request_phase()
click to toggle source
Override de método ‘request_phase` para enviar el parámetro de lang/locale:
# File lib/omniauth/strategies/naranya_id.rb, line 28 def request_phase request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params) session['oauth'] ||= {} session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} # Setup de parametros de lang/locale: authorize_params = options[:authorize_params].merge locale_params if request_token.callback_confirmed? redirect request_token.authorize_url authorize_params else redirect request_token.authorize_url(authorize_params.merge(:oauth_callback => callback_url)) end rescue ::Timeout::Error => e fail!(:timeout, e) rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e fail!(:service_unavailable, e) end
sdk_key_or_secret_missing?()
click to toggle source
Indicates if the SDK’s api key + secret are missing
# File lib/omniauth/strategies/naranya_id.rb, line 84 def sdk_key_or_secret_missing? !(::NaranyaId.consumer_key && ::NaranyaId.consumer_secret) end
Private Instance Methods
locale_params()
click to toggle source
# File lib/omniauth/strategies/naranya_id.rb, line 104 def locale_params _loc_params = {} params = request.params.with_indifferent_access client_locale = if params[:locale].present? params[:locale] end if client_locale.present? # If the complete locale is not available, we'll use the language part of the client locale: client_language = client_locale.split('-').first # User the client_locale or the client_language, if the former is not available: if defined?(I18n) && I18n.respond_to?(:locale_available?) && I18n.respond_to?(:locale) if I18n.locale_available? client_locale _loc_params[:locale] = client_locale _loc_params[:lang] = client_language OmniAuth.logger.debug "The client's locale '#{client_locale}' is available in the app, and will be sent to OAuth site" else OmniAuth.logger.debug "The client's locale '#{client_locale}' is not available in the app, and will not be sent to OAuth site" end end end _loc_params end