Skip to content

Sync with intridea/omniauth-ldap #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from Feb 1, 2014
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9d632a8
Added Net::LDAP::Entry object to strategies test
syndicut Jul 3, 2012
b524feb
Added respond_to? check to user mapping function
syndicut Jul 3, 2012
77eb81a
Use fail!(:missing_credentials) instead of raising custom exception
Sep 27, 2012
9a73d14
Unify formatting in spec files, remove trailing whitespace
Sep 27, 2012
e2664b7
Use #let instead of defineing methods in specs
Sep 27, 2012
78632d2
Rewrite LDAP strategy spec to specify conditions for each test case
Sep 27, 2012
df7a8d0
Add cases when username is empty to strategy spec
Sep 27, 2012
987a81f
Do not allow to sign in using blank username or blank password
Sep 27, 2012
fa90d49
Add the possibility to specify a custom LDAP filter
sdeframond Oct 16, 2012
7f66cff
Add some ducomentation
sdeframond Oct 16, 2012
ef89fe7
Merge pull request #23 from DimaD/master
Jan 23, 2013
77e842e
increased the version
Jan 23, 2013
2c0cc45
add license information to gemspec
jordimassaguerpla Feb 5, 2013
fe216a1
gitignore Gemfile.lock
Feb 13, 2013
5cd2771
Update net-ldap
leoasis Feb 27, 2013
6e9537b
Add two missing commas to example code
rcsheets Mar 5, 2013
b4af89c
Merge branch 'map-userinfo-fix' of github.com:syndicut/omniauth-ldap …
Dec 11, 2013
256c3d4
removed the rspec deprecation.
Dec 11, 2013
a47a72a
Merge pull request #25 from jordimassaguerpla/master
Dec 11, 2013
62bc4f0
Merge pull request #28 from docwhat/gemfile_lock
Dec 11, 2013
232e088
Merge pull request #30 from leoasis/master
Dec 11, 2013
2211893
removed the @url variable and construct_uri method
Dec 11, 2013
120487f
Merge pull request #32 from rcsheets/master
Dec 11, 2013
5ef14bb
increased the version to 1.0.4
Dec 11, 2013
efa1abc
Merge branch 'master' of github.com:intridea/omniauth-ldap
Dec 11, 2013
7aa1386
Merge branch 'master' of github.com:webagecorp/omniauth-ldap into web…
Dec 13, 2013
76d7754
Merge branch 'master' of https://github.com/intridea/omniauth-ldap
Jan 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/omniauth/strategies/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,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
Expand Down
33 changes: 19 additions & 14 deletions spec/omniauth/strategies/ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,25 @@ class MyLdapProvider < OmniAuth::Strategies::LDAP; end
let(:auth_hash){ last_request.env['omniauth.auth'] }

before(:each) do
@adaptor.stub(:bind_as).and_return({
:dn => ['cn=ping, dc=intridea, dc=com'],
:mail => ['ping@intridea.com'],
:givenname => ['Ping'], :sn => ['Yu'],
:telephonenumber => ['555-555-5555'],
:mobile => ['444-444-4444'],
:uid => ['ping'],
:title => ['dev'],
:address =>[ 'k street'],
:l => ['Washington'], :st => ['DC'], :co => ["U.S.A"], :postofficebox => ['20001'],
:wwwhomepage => ['www.intridea.com'],
:jpegphoto => ['http://www.intridea.com/ping.jpg'],
:description => ['omniauth-ldap']})

@adaptor.stub(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
%Q{dn: cn=ping, dc=intridea, dc=com
mail: ping@intridea.com
givenname: Ping
sn: Yu
telephonenumber: 555-555-5555
mobile: 444-444-4444
uid: ping
title: dev
address: k street
l: Washington
st: DC
co: U.S.A
postofficebox: 20001
wwwhomepage: www.intridea.com
jpegphoto: http://www.intridea.com/ping.jpg
description: omniauth-ldap
}
))
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
end

Expand Down