class OmniAuth::Strategies::MojeID
Public Instance Methods
request_phase()
click to toggle source
Called by omniauth when /auth/mojeid is opened.
# File lib/omniauth/strategies/mojeid.rb, line 22 def request_phase openid = Rack::OpenID.new(dummy_app, options[:store]) response = openid.call(env) case env['rack.openid.response'] when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse fail!(:connection_failed) else response end end
Private Instance Methods
ax_user_info()
click to toggle source
Extract all available user user profile attributes. www.mojeid.cz/files/mojeid/mojeid_technicky.pdf
# File lib/omniauth/strategies/mojeid.rb, line 70 def ax_user_info ax = ::OpenID::AX::FetchResponse.from_success_response(openid_response) return {} unless ax Hash[ MOJE_ID.map { |key,att| [key,ax.get_single(att)] } ].reject{|k,v| v.nil? || v == ''} end
dummy_app()
click to toggle source
Simple app that builds the request.
# File lib/omniauth/strategies/mojeid.rb, line 47 def dummy_app lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header( :identifier => identifier, :return_to => callback_url, :required => options.required.map { |att| MOJE_ID[att] || att }, :optional => options.optional.map { |att| MOJE_ID[att] || att }, :method => 'post' )}, []]} end
sreg_user_info()
click to toggle source
Extract SReg attributes. openid.net/specs/openid-simple-registration-extension-1_0.html
# File lib/omniauth/strategies/mojeid.rb, line 59 def sreg_user_info sreg = ::OpenID::SReg::Response.from_success_response(openid_response) return {} unless sreg attrs = %w{fullname nickname dob email gender postcode country language timezone} Hash[ attrs.map { |att| [att, sreg[att]] } ].reject{|k,v| v.nil? || v == ''} end