Module: QuickSearch::Auth

Extended by:
ActiveSupport::Concern
Included in:
AppstatsController, PagesController
Defined in:
app/controllers/concerns/quick_search/auth.rb

Constant Summary collapse

SALT01 =
SecureRandom.hex(512)
SALT02 =
SecureRandom.hex(512)
REALM =
"Please enter the username and password to access this page"
USERS =
{"#{QuickSearch::Engine::APP_CONFIG['user']}" => Digest::MD5.hexdigest(["#{QuickSearch::Engine::APP_CONFIG['user']}",REALM,"#{QuickSearch::Engine::APP_CONFIG['password']}"].join(":"))}
SALTY =
SALT01 + Digest::MD5.hexdigest(["#{QuickSearch::Engine::APP_CONFIG['user']}",REALM,"#{QuickSearch::Engine::APP_CONFIG['password']}"].join(":")) + SALT02

Instance Method Summary collapse

Instance Method Details

#authObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/concerns/quick_search/auth.rb', line 12

def auth
  authenticate_or_request_with_http_digest(REALM) do |username|
    unless SALT01.blank? or SALT02.blank? or USERS[username].blank?
      if SALT01 + USERS[username] + SALT02 == SALTY
        USERS[username]
      end
    end
  end
end