Class: Riddl::Utils::OAuth2::UnivieApp::VerifyIdentity
- Inherits:
-
Implementation
- Object
- Implementation
- Riddl::Utils::OAuth2::UnivieApp::VerifyIdentity
- Defined in:
- lib/ruby/riddl/utils/oauth2-univie.rb
Instance Method Summary collapse
Methods inherited from Implementation
#headers, #initialize, #status
Constructor Details
This class inherits a constructor from Riddl::Implementation
Instance Method Details
#response ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ruby/riddl/utils/oauth2-univie.rb', line 83 def response code = Base64::urlsafe_decode64 @p[0].value access_tokens = @a[0] refresh_tokens = @a[1] client_id = @a[2] client_secret = @a[3] adur = @a[4] rdur = @a[5] client_pass = "#{client_id}:#{client_secret}" user_id, decrypted = Riddl::Utils::OAuth2::Helper::decrypt_with_shared_secret(code, client_pass).split(':', 2) rescue [nil,nil] if user_id.nil? @status = 403 return Riddl::Parameter::Complex.new('data', 'application/json', { :error => 'Code invalid. Client_id or client_secret not suitable for decryption.' }.to_json) else token, refresh_token = Riddl::Utils::OAuth2::Helper::generate_optimistic_token(client_id, client_pass, adur, rdur) access_tokens.set(token, user_id, adur) refresh_tokens.set(refresh_token, token, rdur) json_response = { :access_token => token, :refresh_token => refresh_token, :code => Base64.urlsafe_encode64(decrypted) }.to_json Riddl::Parameter::Complex.new('data', 'application/json', json_response) end end |