Ruby on Rails中Authlogic LDAP如何实现加密通信?

2026-04-10 06:291阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计320个文字,预计阅读时间需要2分钟。

Ruby on Rails中Authlogic LDAP如何实现加密通信?

我在一个Rails应用中使用authlogic和LDAP,但问题是我可以看到日志文件中的所有用户密码,是否需要对这些密码进行加密?对于LDAP,我使用的是encryption simple TLS,感谢你的帮助。

我有一个带有authlogic和LDAP的rails应用程序,但我的问题是我可以看到日志文件中的所有用户密码,是否有一些东西需要修复以加密这些密码.
对于ldap我使用:encryption simple_TLS

谢谢你的帮助

这是我用 authlogic和 net-ldap做的方式:

配置/ ldap.yml

production: host: localhost port: 636 base: ou=people,dc=mydomain admin_user: cn=admin,dc=mydomain admin_password: password ssl: true

应用程序/模型/ ldap_connect.rb

class LdapConnect attr_reader :ldap def initialize(params = {}) ldap_config = YAML.load_file("#{RAILS_ROOT}/config/ldap.yml")[RAILS_ENV] ldap_options = params ldap_options[:encryption] = :simple_tls if ldap_config["ssl"] @ldap = Net::LDAP.new(ldap_options) @ldap.host = ldap_config["host"] @ldap.port = ldap_config["port"] @ldap.base = ldap_config["base"] @ldap.auth ldap_config["admin_user"], ldap_config["admin_password"] if params[:admin] end end

应用程序/模型/ user_session.rb

Ruby on Rails中Authlogic LDAP如何实现加密通信?

class UserSession < Authlogic::Session::Base verify_password_method :valid_ldap_credentials? end

应用程序/模型/ user.rb

class User < ActiveRecord::Base acts_as_authentic do |c| c.validate_password_field = false c.logged_in_timeout = 30.minutes end def dn "cn=#{self.email},ou=people,dc=mydomain" end def valid_ldap_credentials?(password_plaintext) ldap = LdapConnect.new.ldap ldap.auth self.dn, password_plaintext ldap.bind # will return false if authentication is NOT successful end end

本文共计320个文字,预计阅读时间需要2分钟。

Ruby on Rails中Authlogic LDAP如何实现加密通信?

我在一个Rails应用中使用authlogic和LDAP,但问题是我可以看到日志文件中的所有用户密码,是否需要对这些密码进行加密?对于LDAP,我使用的是encryption simple TLS,感谢你的帮助。

我有一个带有authlogic和LDAP的rails应用程序,但我的问题是我可以看到日志文件中的所有用户密码,是否有一些东西需要修复以加密这些密码.
对于ldap我使用:encryption simple_TLS

谢谢你的帮助

这是我用 authlogic和 net-ldap做的方式:

配置/ ldap.yml

production: host: localhost port: 636 base: ou=people,dc=mydomain admin_user: cn=admin,dc=mydomain admin_password: password ssl: true

应用程序/模型/ ldap_connect.rb

class LdapConnect attr_reader :ldap def initialize(params = {}) ldap_config = YAML.load_file("#{RAILS_ROOT}/config/ldap.yml")[RAILS_ENV] ldap_options = params ldap_options[:encryption] = :simple_tls if ldap_config["ssl"] @ldap = Net::LDAP.new(ldap_options) @ldap.host = ldap_config["host"] @ldap.port = ldap_config["port"] @ldap.base = ldap_config["base"] @ldap.auth ldap_config["admin_user"], ldap_config["admin_password"] if params[:admin] end end

应用程序/模型/ user_session.rb

Ruby on Rails中Authlogic LDAP如何实现加密通信?

class UserSession < Authlogic::Session::Base verify_password_method :valid_ldap_credentials? end

应用程序/模型/ user.rb

class User < ActiveRecord::Base acts_as_authentic do |c| c.validate_password_field = false c.logged_in_timeout = 30.minutes end def dn "cn=#{self.email},ou=people,dc=mydomain" end def valid_ldap_credentials?(password_plaintext) ldap = LdapConnect.new.ldap ldap.auth self.dn, password_plaintext ldap.bind # will return false if authentication is NOT successful end end