Project

General

Profile

fix_9858.diff

Marek Hulán, 03/23/2015 03:01 AM

View differences:

app/models/auth_sources/auth_source_ldap.rb
72 72

  
73 73
  def to_config(login = nil, password = nil)
74 74
    raise ::Foreman::Exception.new(N_('Cannot create LDAP configuration for %s without dedicated service account'), self.name) if login.nil? && use_user_login_for_service?
75
    { :host    => host,    :port => port, :encryption => (tls ? :simple_tls : nil),
75
    { :host    => host,    :port => port, :encryption => encryption_config,
76 76
      :base_dn => base_dn, :group_base => groups_base, :attr_login => attr_login,
77 77
      :server_type  => server_type.to_sym, :search_filter => ldap_filter,
78 78
      :anon_queries => account.blank?, :service_user => service_user(login),
79 79
      :service_pass => use_user_login_for_service? ? password : account_password }
80 80
  end
81 81

  
82
  def encryption_config
83
    method = tls ? :simple_tls : nil
84
    { :method => method, :tls_options => { :verify_mode => OpenSSL::SSL::VERIFY_PEER } }
85
  end
86

  
82 87
  def ldap_con(login = nil, password = nil)
83 88
    if login.present?
84 89
      LdapFluff.new(self.to_config(login, password))