Class: OmniAuth::Strategies::OpenIDConnect
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::OpenIDConnect
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/pixelpin.rb
Defined Under Namespace
Classes: CallbackError
Instance Method Summary collapse
- #address ⇒ Object
- #authorization_code ⇒ Object
- #authorize_uri ⇒ Object
- #callback_phase ⇒ Object
- #client ⇒ Object
- #config ⇒ Object
- #formatted_address ⇒ Object
- #public_key ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#address ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 53 def address if formatted_address["address"].nil? address = JSON.parse('{ "street_address": "", "country": "", "region": "", "locality": "", "postal_code": "" }') else address = ActiveSupport::JSON.decode(formatted_address["address"]) end end |
#authorization_code ⇒ Object
148 149 150 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 148 def request.params["code"] end |
#authorize_uri ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 152 def client.redirect_uri = .redirect_uri opts = { response_type: .response_type, scope: .scope, state: new_state, nonce: (new_nonce if .send_nonce), hd: .hd, } client.(opts.reject{|k,v| v.nil?}) end |
#callback_phase ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 123 def callback_phase error = request.params['error_reason'] || request.params['error'] if error raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri']) elsif request.params['state'].to_s.empty? || request.params['state'] != stored_state return Rack::Response.new(['401 Unauthorized'], 401).finish elsif !request.params["code"] return fail!(:missing_code, OmniAuth::OpenIDConnect::MissingCodeError.new(request.params["error"])) else .issuer = issuer if .issuer.blank? discover! if .discovery client.redirect_uri = .redirect_uri client. = access_token super end rescue CallbackError => e fail!(:invalid_credentials, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e) end |
#client ⇒ Object
105 106 107 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 105 def client @client ||= ::OpenIDConnect::Client.new() end |
#config ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 109 def config = { host:.host, port:.port } @config ||= ::OpenIDConnect::Discovery::Provider::Config.discover!(.issuer, = [.host, .port]) end |
#formatted_address ⇒ Object
49 50 51 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 49 def formatted_address formatted_address = HashWithIndifferentAccess.new(user_info.raw_attributes) end |
#public_key ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 164 def public_key if .discovery config.jwks else key_or_secret end end |
#request_phase ⇒ Object
117 118 119 120 121 |
# File 'lib/omniauth/strategies/pixelpin.rb', line 117 def request_phase .issuer = issuer if .issuer.blank? discover! if .discovery redirect end |