-
Notifications
You must be signed in to change notification settings - Fork 27
Accept depth as option for Recursive membership validator strategy constructor #73
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
Changes from all commits
9b820ee
4c2dc84
ec8ee6c
d724036
51e2732
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,31 @@ class Recursive < Base | |
DEFAULT_MAX_DEPTH = 9 | ||
ATTRS = %w(dn cn) | ||
|
||
def perform(entry, depth = DEFAULT_MAX_DEPTH) | ||
# Internal: The maximum depth to search for membership. | ||
attr_reader :depth | ||
|
||
# Public: Instantiate new search strategy. | ||
# | ||
# - ldap: GitHub::Ldap object | ||
# - groups: Array of Net::LDAP::Entry group objects | ||
# - options: Hash of options | ||
# depth: Integer limit of recursion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jch documented |
||
# | ||
# NOTE: This overrides default behavior to configure `depth`. | ||
def initialize(ldap, groups, options = {}) | ||
super | ||
@depth = options[:depth] || DEFAULT_MAX_DEPTH | ||
end | ||
|
||
def perform(entry, depth_override = nil) | ||
if depth_override | ||
warn "DEPRECATION WARNING: Calling Recursive#perform with a second argument is deprecated." | ||
warn "Usage:" | ||
warn " strategy = GitHub::Ldap::MembershipValidators::Recursive.new \\" | ||
warn " ldap, depth: 5" | ||
warn " strategy#perform(entry)" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jch added deprecation warning. |
||
|
||
# short circuit validation if there are no groups to check against | ||
return true if groups.empty? | ||
|
||
|
@@ -36,7 +60,7 @@ def perform(entry, depth = DEFAULT_MAX_DEPTH) | |
next if membership.empty? | ||
|
||
# recurse to at most `depth` | ||
depth.times do |n| | ||
(depth_override || depth).times do |n| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jch use param if set, falling back to configured |
||
# find groups whose members include membership groups | ||
membership = domain.search(filter: membership_filter(membership), attributes: ATTRS) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would document the
depth
attribute here.