Module: Shaf::Authenticator
- Defined in:
- lib/shaf/authenticator.rb,
lib/shaf/authenticator/base.rb,
lib/shaf/authenticator/request.rb,
lib/shaf/authenticator/challenge.rb,
lib/shaf/authenticator/parameter.rb,
lib/shaf/authenticator/basic_auth.rb
Defined Under Namespace
Classes: Base, BasicAuth, Challenge, Parameter, Request
Class Method Summary
collapse
Class Method Details
.challenges_for(realm: nil) ⇒ Object
16
17
18
19
20
|
# File 'lib/shaf/authenticator.rb', line 16
def challenges_for(realm: nil)
authenticators.each_with_object([]) do |authenticator, challenges|
challenges.concat Array(authenticator.challenges_for(realm))
end
end
|
.register(authenticator) ⇒ Object
8
9
10
|
# File 'lib/shaf/authenticator.rb', line 8
def register(authenticator)
authenticators << authenticator
end
|
.unregister(authenticator) ⇒ Object
12
13
14
|
# File 'lib/shaf/authenticator.rb', line 12
def unregister(authenticator)
authenticators.delete_if { |auth| auth == authenticator }
end
|
.user(env, realm: nil) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/shaf/authenticator.rb', line 22
def user(env, realm: nil)
request = Request.new(env)
return unless request.provided?
authenticator = authenticator_for(request)
authenticator&.user(request, realm: realm)
end
|