Class: Riddl::Utils::OAuth2::UnivieApp::VerifyIdentity

Inherits:
Implementation
  • Object
show all
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

#responseObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ruby/riddl/utils/oauth2-univie.rb', line 90

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]

  client_pass   = "#{client_id}:#{client_secret}"
  user_id, decrypted            = Riddl::Utils::OAuth2::Helper::decrypt_with_shared_secret(code, client_pass).split(':', 2)
  token, refresh_token          = Riddl::Utils::OAuth2::Helper::generate_optimistic_token(client_id, client_pass)
  access_tokens[token]          = user_id
  refresh_tokens[refresh_token] = token

  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