Class: Rapid::Server::AuthRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/ury_rapid/server/auth_request.rb

Overview

A request for authentication

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authenticator, rack_request) ⇒ AuthRequest

Initialises an AuthRequest

It may be more convenient to use the .request method instead.

Parameters:

  • authenticator (Object)

    The Kankri (or compatible) authenticator object to use when validating credentials.

  • rack_request (Object)

    The Rack authentication request from which credentials should be extracted.


14
15
16
17
18
19
20
# File 'lib/ury_rapid/server/auth_request.rb', line 14

def initialize(authenticator, rack_request)
  fail_authenticator_is_nil          if authenticator.nil?
  fail_authenticator_cannot_auth unless can_auth?(authenticator)

  @authenticator = authenticator
  @rack_request  = rack_request
end

Class Method Details

.request(*args) ⇒ Object

Initialises and runs an AuthRequest

See #initialize for details on which arguments to send here.


25
26
27
# File 'lib/ury_rapid/server/auth_request.rb', line 25

def self.request(*args)
  AuthRequest.new(*args).run
end

Instance Method Details

#runArray

Runs an AuthRequest

Returns:

  • (Array)

    An array of privilege symbols.


32
33
34
# File 'lib/ury_rapid/server/auth_request.rb', line 32

def run
  @authenticator.authenticate(*credentials)
end