Skip to content
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

Versatile group filter #36

Merged
merged 3 commits into from
Aug 10, 2016
Merged

Versatile group filter #36

merged 3 commits into from
Aug 10, 2016

Conversation

UXabre
Copy link

@UXabre UXabre commented Jun 16, 2016

As mentioned in an issue some days ago, I have patched the groupfilter to allow for passing of a callback function next to the previously defined string. The first and only argument passed is the user object, which can be used to form a search filter string which needs to be returned.

I have tried out both the "old" functionality with a fixed string and tested it out with a dynamic filter:

groupSearchFilter: (user) => {
    return "(|(&(cn=*)(memberUid="+user.uid+"))(&(cn=*)(gidNumber="+user.gidNumber+")))";
}

Arend Lapere added 2 commits June 16, 2016 07:05
but to dynamically generate a groupSearchFilter from a passed function with the user as argument

Tested with both a fixed string as with a generated string
but to dynamically generate a groupSearchFilter from a passed function with the user as argument

Tested with both a fixed string as with a generated string
var searchFilter = self.opts.groupSearchFilter.replace(/{{dn}}/g, user[self.opts.groupDnProperty]);
var searchFilter = '';

if ((typeof (self.opts.groupSearchFilter) === 'string')) {
Copy link
Owner

@vesse vesse Jun 21, 2016

Choose a reason for hiding this comment

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

Could you instead of this setup a function in the constructor, eg. something like this

if (typeof opts.groupSearchFilter === 'function') {
  this.groupSearchFilter = opts.groupSearchFilter;
} else {
  this.groupSearchFilter = function(user) {
    return opts.groupSearchFilter.replace(...);
  };
}

Then the authentication function would just do var searchFilter = self.groupSearchFilter(user);. I think it would look cleaner that way.

but to dynamically generate a groupSearchFilter from a passed function with the user as argument

Tested with both a fixed string as with a generated string
@UXabre
Copy link
Author

UXabre commented Jun 22, 2016

I have updated the pull request as per your comment. I have done it slightly different but I think it is in line with what you mentioned :-)

@UXabre
Copy link
Author

UXabre commented Aug 9, 2016

Hello,
Were you able to review the latest changes? Or did I overlook some things to be according to your specification? :-)

@vesse
Copy link
Owner

vesse commented Aug 10, 2016

Hello,

Yes and then left to vacation and forgot the whole thing... Sorry about that.

@vesse vesse merged commit e55d299 into vesse:master Aug 10, 2016
@UXabre UXabre deleted the versatile_group_filter branch August 10, 2016 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants