Class: Aspera::WebAuth::Servlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Includes:
ServletHelpers
Defined in:
lib/aspera/web_auth/server.rb

Overview

servlet called on callback: it records the callback request

Instance Method Summary collapse

Methods included from ServletHelpers

#authorization, #basic_authorized?, #check_request, host_name, #json_error, #json_response, origin, same_origin?

Constructor Details

#initialize(server, web_auth) ⇒ Servlet

Returns a new instance of Servlet.

Parameters:

  • server (WEBrick::HTTPServer) —

    the HTTP server instance

  • web_auth (Server) —

    the Server instance to record the callback



31
32
33
34
35
# File 'lib/aspera/web_auth/server.rb', line 31

def initialize(server, web_auth)
  Log.log.debug('Servlet initialize')
  super(server)
  @web_auth = web_auth
end

Instance Method Details

#service(request, response) ⇒ Object

called on request



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/aspera/web_auth/server.rb', line 39

def service(request, response)
  Log.log.debug { "received request from browser #{request.request_method} #{request.path}" }
  # Refuse requests of other web pages
  check_request(request)
  Aspera.assert_values(request.request_method, ['GET'], type: WEBrick::HTTPStatus::MethodNotAllowed) { "Unsupported method: #{request.request_method}" }
  Aspera.assert_values(request.path, [@web_auth.expected_path], type: WEBrick::HTTPStatus::NotFound) { "Unsupported path: #{request.path}" }
  # response to browser
  response.status = 200
  if @web_auth.reply_keys.nil?
    WebPage.secure_headers(response)
    response.body = WebPage.render(HTML_TEMPLATE_PATH, title: 'Authentication Complete', additional_info: @web_auth.additional_info)
  else
    render_reply(request, response)
  end
  # continue internal processing
  @web_auth.signal_request(request)
  nil
end