Class: CF::UAA::TokenCatcher

Inherits:
Stub::Base show all
Defined in:
lib/uaa/cli/token.rb

Instance Attribute Summary

Attributes inherited from Stub::Base

#match, #reply, #request, #server

Instance Method Summary collapse

Methods inherited from Stub::Base

#default_route, find_route, #initialize, #process, #reply_in_kind, route

Constructor Details

This class inherits a constructor from Stub::Base

Instance Method Details

#process_grant(data) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/uaa/cli/token.rb', line 23

def process_grant(data)
  server.logger.debug "processing grant for path #{request.path}"
  secret = server.info.delete(:client_secret)
  do_authcode = server.info.delete(:do_authcode)
  ti = TokenIssuer.new(Config.target, server.info.delete(:client_id), secret,
      { token_target: Config.target_value(:token_target),
        basic_auth: Config.target_value(:basic_auth),
        use_pkce: true,
        code_verifier: server.info.delete(:code_verifier),
        skip_ssl_validation: Config.target_value(:skip_ssl_validation)})
  tkn = do_authcode ? ti.authcode_grant(server.info.delete(:uri), data) :
      ti.implicit_grant(server.info.delete(:uri), data)
  server.info.update(token_info: tkn.info)
  reply.text "you are now logged in and can close this window"
rescue TargetError => e
  reply.text "#{e.message}:\r\n#{Util.json_pretty(e.info)}\r\n#{e.backtrace}"
rescue Exception => e
  reply.text "#{e.message}\r\n#{e.backtrace}"
ensure
  server.logger.debug "reply: #{reply.body}"
end