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

Bugfix and overrides #72

Merged
merged 21 commits into from
Jul 1, 2020
Merged

Bugfix and overrides #72

merged 21 commits into from
Jul 1, 2020

Conversation

blag
Copy link
Contributor

@blag blag commented Jun 20, 2020

In some cases users will need to override the account and group LDAP query patterns, and we previously did not enable this. This PR adds this feature, and it inadvertently fixes a DRY bug regarding the default value of the id_attr configuration option.

I had to refactor the _get_groups_for_user method a bit, but it converts from using filter_format, which just called escape_filter_chars:

def filter_format(filter_template, assertion_values):
  return filter_template % tuple(escape_filter_chars(v) for v in assertion_values)

to using escape_filter_chars directly:

filter_values = {
    'user_dn': ldap.filter.escape_filter_chars(user_dn),
    'username': ldap.filter.escape_filter_chars(username),
}
query = self._group_pattern % filter_values

@blag
Copy link
Contributor Author

blag commented Jun 20, 2020

I will need to update the enterprise docs. I'll work on a PR for that on Monday.

@nmaludy
Copy link
Member

nmaludy commented Jun 20, 2020

Can you give an example, maybe in the README, of how one might use this?

@blag
Copy link
Contributor Author

blag commented Jun 26, 2020

Added an overview of what this plugin actually does regarding LDAP, and added descriptions to the table of options for the new account_pattern and group_pattern options, as well as two more examples: one for simply specifying id_attr, and another for overriding both account_pattern and group_pattern (including a note that you don't have to override both at the same time). 👍

Also fixed a few Markdown syntax typos that GitHub was rendering properly, but should still be fixed regardless.

Copy link
Member

@nmaludy nmaludy left a comment

Choose a reason for hiding this comment

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

LGTM!

@blag
Copy link
Contributor Author

blag commented Jun 26, 2020

I should also add some tests for these new options... I'll do that tomorrow.

Copy link
Member

@nmaludy nmaludy left a comment

Choose a reason for hiding this comment

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

Great work, this is an awesome change!

@blag blag merged commit 0f81bd0 into master Jul 1, 2020
@nmaludy nmaludy deleted the bugfix-and-overrides branch July 1, 2020 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants