From 37170e58775fdae562aad8a6cfd96c0e558ca2c7 Mon Sep 17 00:00:00 2001 From: Simon Stueckemann Date: Mon, 22 Jun 2015 18:09:42 +0100 Subject: [PATCH] Added "development" environment to those that accept "test:test" --- .../kerberos_adapter.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/devise_kerberos_authenticatable/kerberos_adapter.rb b/lib/devise_kerberos_authenticatable/kerberos_adapter.rb index 4f5ca1a..995df69 100644 --- a/lib/devise_kerberos_authenticatable/kerberos_adapter.rb +++ b/lib/devise_kerberos_authenticatable/kerberos_adapter.rb @@ -4,19 +4,26 @@ include Krb5Auth module Devise module KerberosAdapter 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 end krb5 = Krb5.new - username_with_realm = "#{username}@#{::Devise.kerberos_realm}" begin - krb5.get_init_creds_password(username_with_realm, password) + krb5.get_init_creds_password(username_with_realm(username), password) rescue Krb5Auth::Krb5::Exception return false end return true end + + def username_with_realm(username) + "#{username}@#{::Devise.kerberos_realm}" + end + + def self.test_environment? + Rails.env.test? || Rails.env.development? + end end end