Class: OmniAuth::Strategies::MakerPass
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::MakerPass
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/makerpass.rb
Defined Under Namespace
Classes: CallbackError
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #authorize_params ⇒ Object
-
#callback_phase ⇒ Object
rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity.
- #callback_url ⇒ Object
- #client ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
- #token_params ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
45 46 47 |
# File 'lib/omniauth/strategies/makerpass.rb', line 45 def access_token @access_token end |
Instance Method Details
#authorize_params ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/omniauth/strategies/makerpass.rb', line 71 def .[:state] = SecureRandom.hex(24) params = ..merge(('authorize')) if OmniAuth.config.test_mode @env ||= {} @env['rack.session'] ||= {} end session['omniauth.state'] = params[:state] params end |
#callback_phase ⇒ Object
rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/omniauth/strategies/makerpass.rb', line 86 def callback_phase # rubocop:disable CyclomaticComplexity, MethodLength, PerceivedComplexity error = request.params['error_reason'] || request.params['error'] if error fail!(error, CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])) elsif !.provider_ignores_state && (request.params['state'].to_s.empty? || request.params['state'] != session.delete('omniauth.state')) fail!(:csrf_detected, CallbackError.new(:csrf_detected, 'CSRF detected')) else self.access_token = build_access_token self.access_token = access_token.refresh! if access_token.expired? super end rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT, Faraday::Error::TimeoutError => e fail!(:timeout, e) rescue ::SocketError, Faraday::Error::ConnectionFailed => e fail!(:failed_to_connect, e) end |
#callback_url ⇒ Object
55 56 57 |
# File 'lib/omniauth/strategies/makerpass.rb', line 55 def callback_url full_host + script_name + callback_path end |
#client ⇒ Object
51 52 53 |
# File 'lib/omniauth/strategies/makerpass.rb', line 51 def client ::OAuth2::Client.new(.client_id, .client_secret, deep_symbolize(.)) end |
#raw_info ⇒ Object
47 48 49 |
# File 'lib/omniauth/strategies/makerpass.rb', line 47 def raw_info @raw_info ||= access_token.get('/api/v1/me.json').parsed end |
#request_phase ⇒ Object
67 68 69 |
# File 'lib/omniauth/strategies/makerpass.rb', line 67 def request_phase redirect client.auth_code.({:redirect_uri => callback_url}.merge()) end |
#token_params ⇒ Object
82 83 84 |
# File 'lib/omniauth/strategies/makerpass.rb', line 82 def token_params .token_params.merge(('token')) end |