Module: Htpasswd::Auths
- Defined in:
- lib/htpasswd/auths/base.rb,
lib/htpasswd/auths/basic.rb,
lib/htpasswd/auths/digest.rb
Defined Under Namespace
Classes: Base, Basic, Digest
Constant Summary
collapse
- @@schemas =
{}
Class Method Summary
collapse
Class Method Details
.[](auth_scheme) ⇒ Object
6
7
8
|
# File 'lib/htpasswd/auths/base.rb', line 6
def [](auth_scheme)
@@schemas[auth_scheme.to_s.classify]
end
|
.default_realm ⇒ Object
38
39
40
|
# File 'lib/htpasswd/auths/base.rb', line 38
def default_realm
"Authorization"
end
|
29
30
31
32
33
34
35
36
|
# File 'lib/htpasswd/auths/base.rb', line 29
def (hash)
[
'X-HTTP_AUTHORIZATION', 'REDIRECT_X_HTTP_AUTHORIZATION', 'Authorization', 'HTTP_AUTHORIZATION', ].map{|name| hash[name]}.compact.first
end
|
.instantiate(header) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/htpasswd/auths/base.rb', line 21
def instantiate()
raise HeaderNotFound if .blank?
ActionController::Base.logger.debug "Htpasswd accepts authorization header: '#{}'"
type, data = .to_s.split(' ', 2)
klass = self[type] or raise UnknownSchemeError, type
klass.parse(data)
end
|
.scheme(controller) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/htpasswd/auths/base.rb', line 10
def scheme(controller)
case controller
when ActionController::Base
returning authorization = instantiate((controller.request.env)) do
authorization.set_controller(controller)
end
else
instantiate(controller.to_s)
end
end
|