From 00ed74eb0d13c16e2f736ab8116f7b62c9b8195a Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 24 Feb 2022 13:59:52 +0100 Subject: [PATCH] Add psych4 support * Psych 4 does not load aliases unless `aliases: true` is provided as an argument * Workaround take from rails: https://github.com/rails/rails/commit/179d0a1f474ada02e0030ac3bd062fc653765dbe --- lib/devise_ldap_authenticatable/ldap/connection.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/devise_ldap_authenticatable/ldap/connection.rb b/lib/devise_ldap_authenticatable/ldap/connection.rb index faefa574cc..072545a4fd 100644 --- a/lib/devise_ldap_authenticatable/ldap/connection.rb +++ b/lib/devise_ldap_authenticatable/ldap/connection.rb @@ -7,7 +7,12 @@ def initialize(params = {}) if ::Devise.ldap_config.is_a?(Proc) ldap_config = ::Devise.ldap_config.call else - ldap_config = YAML.load(ERB.new(File.read(::Devise.ldap_config || "#{Rails.root}/config/ldap.yml")).result)[Rails.env] + source = ERB.new(File.read(::Devise.ldap_config || "#{Rails.root}/config/ldap.yml")).result + begin + ldap_config = YAML.load(source, aliases: true)[Rails.env] + rescue ArgumentError + ldap_config = YAML.load(source)[Rails.env] + end end ldap_options = params