Module: Aspera::WebAuth

Defined in:
lib/aspera/web_auth/paste.rb,
lib/aspera/web_auth/relay.rb,
lib/aspera/web_auth/server.rb,
lib/aspera/web_auth/receiver.rb

Defined Under Namespace

Modules: Relay Classes: Paste, Server, Servlet

Class Method Summary collapse

Class Method Details

.open_login_page(login_receiver, login_url) ⇒ Object

Let the user open the login page, unless the receiver already gives the URL in its own message

Parameters:

  • login_receiver (Server, Paste) —

    Result of receiver

  • login_url (String, URI) —

    URL of the login page



44
45
46
47
# File 'lib/aspera/web_auth/receiver.rb', line 44

def (, )
  return if .is_a?(Paste) && .
  Environment.instance.open_uri()
end

.receiver(redirect_uri, additional_info = nil, login_url: nil, reply_keys: nil) ⇒ Server, Paste

Create the object that receives the result of a web login, according to Environment#web_auth (option ui.web_auth): :port listens on the loopback address of redirect_uri, :paste asks the user to give the result in the terminal. Both provide received_request.

Parameters:

  • redirect_uri (String) —

    Loopback URL that receives the result

  • additional_info (String) (defaults to: nil) —

    Information in web page (only with :port)

  • login_url (String, URI) (defaults to: nil) —

    URL of the login page: with :paste, a code for ascli on the workstation is given to the user, unless the browser is started by ascli (the user has no time to use the code, and the browser is local)

  • reply_keys (Array<String>) (defaults to: nil) —

    Keys of the query that the client needs (with login_url)

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aspera/web_auth/receiver.rb', line 23

def receiver(redirect_uri, additional_info = nil, login_url: nil, reply_keys: nil)
  env = Environment.instance
  case env.web_auth
  when :paste
     = nil if env.browser_command || env.url_method.eql?(:graphical)
    Paste.new(redirect_uri, login_url: , reply_keys: reply_keys)
  when :port
    if env.url_method.eql?(:text) && env.browser_command.nil? && (ENV.key?('SSH_CONNECTION') || ENV.key?('SSH_TTY'))
      Log.log.warn do
        "Web login: the browser must reach port #{URI.parse(redirect_uri).port} of this host (SSH tunnel). " \
          'If not possible, use option --ui.web_auth=paste'
      end
    end
    Server.new(redirect_uri, additional_info)
  else Aspera.error_unexpected_value(env.web_auth) { 'ui.web_auth' }
  end
end