Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
only use trust_basic_auth if auth_basic is used
Browse files Browse the repository at this point in the history
  • Loading branch information
nougad authored and Dennis Reimann committed Jun 20, 2011
1 parent 98e301b commit da866a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/account.rb
Expand Up @@ -67,7 +67,7 @@ def has_otp_device?

# Authenticates a user by their login name and password.
# Returns the user or nil.
def self.authenticate(login, password)
def self.authenticate(login, password, basic_auth_used=false)
a = Account.find_by_login(login)
if a.nil? and Masquerade::Application::Config['create_auth_ondemand']['enabled']
# Need to set some password - but is never used
Expand All @@ -76,7 +76,7 @@ def self.authenticate(login, password)
end

if not a.nil? and a.active? and a.enabled
if a.authenticated?(password) or Masquerade::Application::Config['trust_basic_auth']
if a.authenticated?(password) or (Masquerade::Application::Config['trust_basic_auth'] and basic_auth_used)
a.last_authenticated_at, a.last_authenticated_with_yubikey = Time.now, a.authenticated_with_yubikey?
a.save(:validate => false)
return a
Expand Down
2 changes: 1 addition & 1 deletion lib/authenticated_system.rb
Expand Up @@ -110,7 +110,7 @@ def auth_type_used= t
# Called from #current_account. Now, attempt to login by basic authentication information.
def login_from_basic_auth
authenticate_with_http_basic do |accountname, password|
account = Account.authenticate(accountname, password)
account = Account.authenticate(accountname, password, true)
self.auth_type_used = :basic if not account.nil?
self.current_account = account
account
Expand Down

0 comments on commit da866a1

Please sign in to comment.