Closed leonsp closed 8 years ago
This user had a similar problem, in the sense that their LDAP code was not being run: http://stackoverflow.com/questions/28489814/how-to-debug-custom-devise-strategy-in-rails-4
I've tried upgrading from released gem level (0.8.5) to github master gem level (0.8.6) to no effect.
Excerpt of my user model:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :ldap_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:confirmable, :lockable, :zxcvbnable
I got the model to work with :database_authenticable
before trying :ldap_authenticable
.
I've now monkeypatched find_for_ldap_authentication
in the User
model as well as ldap_auth_username_builder
and Devise::Strategies::LdapAuthenticatable.authenticate!
to write to the debug Rails log before they do anything, and none of them are writing anything to the log.
Why is the LDAP code not being reached?
I'm tracing the execution with byebug
:
[346, 355] in /Users/leonsp/.rvm/gems/ruby-2.2.2/gems/warden-1.2.3/lib/warden/proxy.rb
346: strategies = defaults[scope] || defaults[:_all]
347: end
348:
349: (strategies || args).each do |name|
350: strategy = _fetch_strategy(name, scope)
=> 351: next unless strategy && !strategy.performed? && strategy.valid?
352:
353: self.winning_strategy = @winning_strategies[scope] = strategy
354: strategy._run!
355: break if strategy.halted?
At this point, strategy is an instance of :ldap_authenticatable
, !strategy.performed?
is true, but strategy.valid?
is false.
Why is strategy.valid?
false for :ldap_authenticatable
? I will try to investigate, but this is all new to me.
Immediate issue was due to https://github.com/plataformatec/devise/issues/1255
I had optional keys in config.authentication_keys
. This makes Devise::Strategies#parse_authentication_key_values
fail automatically.
I have logging enabled in
devise.rb
:It shows as enabled in rails console:
However, when I try to sign in, no LDAP debug information is written to the log:
I've disabled all Rails gems that do anything with logging, but I'm still not seeing any LDAP log messages.
I can successfully connect to the LDAP server using
ldapsearch
:ldapsearch -x -W -D "cn=admin,dc=my_domain,dc=com" -H ldap://my_hostname.my_domain.com -b dc=my_domain,dc=com "(cn=leonsp)"
My devise configuration looks the same:
Why is there no LDAP information in the log?
What additional diagnostics can I try or collect?