1
0
Fork 0

Added "development" environment to those that accept "test:test"

This commit is contained in:
Simon Stueckemann 2015-06-22 18:09:42 +01:00
parent 67ababc103
commit 37170e5877

View file

@ -4,19 +4,26 @@ include Krb5Auth
module Devise module Devise
module KerberosAdapter module KerberosAdapter
def self.valid_credentials?(username, password) def self.valid_credentials?(username, password)
if Rails.env.test? && username == 'test' && password == 'test' then if test_environment? && username == 'test' && password == 'test' then
return true return true
end end
krb5 = Krb5.new krb5 = Krb5.new
username_with_realm = "#{username}@#{::Devise.kerberos_realm}"
begin begin
krb5.get_init_creds_password(username_with_realm, password) krb5.get_init_creds_password(username_with_realm(username), password)
rescue Krb5Auth::Krb5::Exception rescue Krb5Auth::Krb5::Exception
return false return false
end end
return true return true
end end
def username_with_realm(username)
"#{username}@#{::Devise.kerberos_realm}"
end
def self.test_environment?
Rails.env.test? || Rails.env.development?
end
end end
end end