问题描述:

I am creating an application for which I am trying to use LDAP with authlogic for login authentication. I want to accept just the username and log the user in if he is on the LDAP server. For this, I need to disable the password validation. How can I do that?

网友答案:

I think you can do it like this:

class User < ActiveRecord::Base
  acts_as_authentic do |config|
    config.validate_password_field = false
  end
end
网友答案:

In your User model where you call acts_as_authentic, this might do the trick:

acts_as_authentic do |config|
  config.require_password_confirmation = false
  config.ignore_blank_passwords = true
end

These config options, among others, can be found in lib/authlogic/acts_as_authentic/password.rb (in version 2.1.3).

网友答案:

I had the same issue with the authlogic_ldap addon that I modified for my app. I make the mistake of including login_field :ldap_login in the User class. I also had a stack level too deep error initially, but I reverted authlogic from v3.0.3 to v3.0.2 and it works now.

网友答案:

I was successful doing this with Open ID (same idea, password not stored by my app) by not having a password column in the users table and using this config for Authlogic:

class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.crypted_password_field = false
  end
end

Without setting crypted_password_field, there were errors generated during user saves.

相关阅读:
Top