Class: Hadley::Authz::Basic::Strategy

Inherits:
Strategy
  • Object
show all
Defined in:
lib/hadley/authz/basic.rb

Overview

This class is the prototype class for all HTTP Basic authorization strategies used by hadley.

Instance Method Summary collapse

Methods inherited from Strategy

#config

Methods included from StrategyBuilder

#build, #create_strategy, #register_strategy, #set_config

Instance Method Details

#authRack::Aauth::Basic::Request

Provides access to the HTTP Basic Auth information assiciated with the current request.

Returns:

  • (Rack::Aauth::Basic::Request)

    The HTTP Basic Auth information associated with the current request.



10
11
12
# File 'lib/hadley/authz/basic.rb', line 10

def auth
  @auth ||= Rack::Auth::Basic::Request.new(env)
end

#authenticate!Object

Authenticates the entity identified by the provided HTTP Basic Auth information



24
25
26
27
28
29
30
31
# File 'lib/hadley/authz/basic.rb', line 24

def authenticate!
  return unauthorized 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) : unauthorized
end

#store?Boolean

Identifies whether a login using this strategy should be persisted across multiple requests.

Returns:

  • (Boolean)

    true if and only if a login using this strategy should be persistent across multiple requests.

See Also:

  • Warden::Strategies::Base#store?


19
20
21
# File 'lib/hadley/authz/basic.rb', line 19

def store?
  false
end