Skip to content

Pass through search options for GitHub::Ldap::Domain#user? #51

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 2 commits into from
Oct 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions lib/github/ldap/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,15 @@ def valid_login?(login, password)
# Check if a user exists based in the `uid`.
#
# login: is the user's login
# search_options: Net::LDAP#search compatible options to pass through
#
# Returns the user if the login matches any `uid`.
# Returns nil if there are no matches.
def user?(login)
search(filter: login_filter(@uid, login), size: 1).first
def user?(login, search_options = {})
options = search_options.merge \
filter: login_filter(@uid, login),
size: 1
search(options).first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the separate options vs search_options hash needed? Seems like it'd be fine to combine them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided against modify the search_options in place in case the caller was using it as a common hash to build up other queries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 legit.

end

# Check if a user can be bound with a password.
Expand Down
5 changes: 5 additions & 0 deletions test/domain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def test_user_returns_every_attribute
assert_equal ['user1@github.com'], user[:mail]
end

def test_user_returns_subset_of_attributes
assert entry = @domain.user?('user1', :attributes => [:cn])
assert_equal [:dn, :cn], entry.attribute_names
end

def test_auth_binds
assert user = @domain.user?('user1')
assert @domain.auth(user, 'passworD1'), 'Expected user to bind'
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy