Class: OmniAuth::Strategies::Gorgias
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Gorgias
- Defined in:
- lib/omniauth/strategies/gorgias.rb
Instance Method Summary collapse
- #account ⇒ Object
- #account_present? ⇒ Boolean
- #authorize_params ⇒ Object
- #callback_url ⇒ Object
- #request_phase ⇒ Object
- #token_params ⇒ Object
Instance Method Details
#account ⇒ Object
51 52 53 |
# File 'lib/omniauth/strategies/gorgias.rb', line 51 def account @account ||= request.params['account'] end |
#account_present? ⇒ Boolean
55 56 57 |
# File 'lib/omniauth/strategies/gorgias.rb', line 55 def account_present? !!(account =~ /\A[a-z0-9][a-z0-9\-]*\z/i) end |
#authorize_params ⇒ Object
31 32 33 34 35 36 |
# File 'lib/omniauth/strategies/gorgias.rb', line 31 def nonce = SecureRandom.hex(16) session['omniauth.nonce'] = nonce super.merge(nonce: nonce) end |
#callback_url ⇒ Object
38 39 40 |
# File 'lib/omniauth/strategies/gorgias.rb', line 38 def callback_url full_host + script_name + callback_path + "?account=#{account}" end |
#request_phase ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/omniauth/strategies/gorgias.rb', line 20 def request_phase return fail!(:account_missing) unless account_present? [:scope] ||= 'openid' [:response_type] ||= 'code' super end |
#token_params ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/omniauth/strategies/gorgias.rb', line 42 def token_params super.merge( headers: { 'Authorization' => "Basic #{Base64.strict_encode64("#{.client_id}:#{.client_secret}")}" }, redirect_uri: callback_url ) end |