From 346d5c27e1dacb0fa6aeedf1f65e29bd9f1bb524 Mon Sep 17 00:00:00 2001 From: Christoph Loesch Date: Thu, 15 Mar 2018 22:51:54 +0100 Subject: [PATCH] allow bind against the current user added to be able to use %{password} and %{username} in the LDAP omniauth initializer credits @pscdodd https://github.com/omniauth/omniauth-ldap/issues/59#issuecomment-372246080 --- lib/omniauth/strategies/ldap.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/omniauth/strategies/ldap.rb b/lib/omniauth/strategies/ldap.rb index 9a4d880..f2b9c87 100644 --- a/lib/omniauth/strategies/ldap.rb +++ b/lib/omniauth/strategies/ldap.rb @@ -35,6 +35,8 @@ def request_phase end def callback_phase + @options[:password] = @options[:password].sub('%{password}', request['password']) unless request['password'].nil? + @options[:bind_dn] = @options[:bind_dn].sub('%{username}', request['username']) unless request['username'].nil? @adaptor = OmniAuth::LDAP::Adaptor.new @options return fail!(:missing_credentials) if missing_credentials?