1
0
Fork 0
devise-kerberos-authenticat.../lib/devise_kerberos_authenticatable/kerberos_adapter.rb

23 lines
512 B
Ruby
Raw Normal View History

2013-04-21 00:32:23 -04:00
require 'krb5_auth'
include Krb5Auth
module Devise
module KerberosAdapter
def self.valid_credentials?(username, password)
if Rails.env.test? && username == 'test' && password == 'test' then
2014-01-26 09:29:38 -05:00
return true
2013-04-21 00:32:23 -04:00
end
krb5 = Krb5.new
2014-01-31 07:31:11 -05:00
username_with_realm = "#{username}@#{::Devise.kerberos_realm}"
2013-04-21 00:32:23 -04:00
begin
2014-01-31 07:31:11 -05:00
krb5.get_init_creds_password(username_with_realm, password)
2013-04-21 00:32:23 -04:00
rescue Krb5Auth::Krb5::Exception
return false
2013-04-21 00:32:23 -04:00
end
return true
2013-04-21 00:32:23 -04:00
end
end
end