Permalink
Browse files

Added respond_to? check to user mapping function

Net::LDAP::Entry returns empty array if key not
exists, so we should check for key with respond_to?
  • Loading branch information...
syndicut committed Jul 3, 2012
1 parent 9d632a8 commit b524feb63048591a20de0f70c2d597f0b9d6a156
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/omniauth/strategies/ldap.rb
@@ -65,14 +65,14 @@ def self.map_user(mapper, object)
mapper.each do |key, value|
case value
when String
- user[key] = object[value.downcase.to_sym].first if object[value.downcase.to_sym]
+ user[key] = object[value.downcase.to_sym].first if object.respond_to? value.downcase.to_sym
when Array
- value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object[v.downcase.to_sym]}
+ value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object.respond_to? v.downcase.to_sym}
when Hash
value.map do |key1, value1|
pattern = key1.dup
value1.each_with_index do |v,i|
- part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object[v1]}
+ part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object.respond_to? v1}
pattern.gsub!("%#{i}",part||'')
end
user[key] = pattern

7 comments on commit b524feb

@rob-mccann

This comment has been minimized.

Show comment
Hide comment
@rob-mccann

rob-mccann Dec 5, 2012

+1 this was an issue for me to. I manually applied the patch and it began to work as expected. Any chance of a merge?

This issue affects https://github.com/gitlabhq/gitlabhq

+1 this was an issue for me to. I manually applied the patch and it began to work as expected. Any chance of a merge?

This issue affects https://github.com/gitlabhq/gitlabhq

@retiolum

This comment has been minimized.

Show comment
Hide comment
@retiolum

retiolum Aug 9, 2013

As syndicut does not seem to have made a pull request for this improvement, I did it for him (mentioning this diff in my commit) – see omniauth#35.

As syndicut does not seem to have made a pull request for this improvement, I did it for him (mentioning this diff in my commit) – see omniauth#35.

@syndicut

This comment has been minimized.

Show comment
Hide comment
@syndicut

syndicut Aug 11, 2013

Owner

My pull request is here =) intridea#17

Owner

syndicut replied Aug 11, 2013

My pull request is here =) intridea#17

@retiolum

This comment has been minimized.

Show comment
Hide comment
@retiolum

retiolum Aug 21, 2013

Sorry, just overlooked that one. I've closed my pull requested (and voted up on your request – hopefully they'll fix this some time soon now).

Sorry, just overlooked that one. I've closed my pull requested (and voted up on your request – hopefully they'll fix this some time soon now).

@retiolum

This comment has been minimized.

Show comment
Hide comment
@retiolum

retiolum Dec 10, 2013

What do you mean with "it did not change anything"? Doesn't it work for you in GitLab with the patch?

What do you mean with "it did not change anything"? Doesn't it work for you in GitLab with the patch?

@xbgmsharp

This comment has been minimized.

Show comment
Hide comment
@xbgmsharp

xbgmsharp Dec 20, 2013

+1 This fix the LDAP Active Directory authentification for GitLabHQ 6.4 -stable

+1 This fix the LDAP Active Directory authentification for GitLabHQ 6.4 -stable

@Signus

This comment has been minimized.

Show comment
Hide comment
@Signus

Signus Feb 12, 2014

+1 Confirmed fix for LDAP authentication on GitLab 6.5-stable.

+1 Confirmed fix for LDAP authentication on GitLab 6.5-stable.

Please sign in to comment.