Class: Hadley::Authz::Basic::Strategy
- Defined in:
- lib/hadley/authz/basic.rb
Instance Method Summary collapse
Methods inherited from Strategy
Methods included from StrategyBuilder
Instance Method Details
#auth ⇒ Object
9 10 11 |
# File 'lib/hadley/authz/basic.rb', line 9 def auth @auth ||= Rack::Auth::Basic::Request.new(env) end |
#authenticate! ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/hadley/authz/basic.rb', line 17 def authenticate! return unless auth.provided? and auth.basic? and auth.credentials credentials = auth.credentials.map do |credential| config.hash_credentials ? Digest::SHA2.new(256).update(credential).to_s : credential end user = config.lookup.call(credentials.first, credentials.last) return user ? success!(auth.credentials.first) : end |
#store? ⇒ Boolean
13 14 15 |
# File 'lib/hadley/authz/basic.rb', line 13 def store? false end |
#unauthorized ⇒ Object
26 27 28 |
# File 'lib/hadley/authz/basic.rb', line 26 def custom!(Rack::Response.new([config.], 401, { 'WWW-Authenticate' => %Q{Basic realm="#{config.realm}"} })) end |