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

Search for LDAP entry by both username and e-mail + large refactor #47

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

veox
Copy link

@veox veox commented Dec 1, 2016

Most important changes:

  • rename PROPERTY to ATTRIBUTE in settings - that's the proper term;
  • remove LDAP_SEARCH_SUFFIX - guess this was a workaround for searching e-mails;
  • remove LDAP_SEARCH_PROPERTY and add LDAP_USERNAME_ATTRIBUTE;
  • perform LDAP search operations by both LDAP_{USERNAME,EMAIL}_ATTRIBUTE by default - login form says "Username or email";
  • rename LDAP_SEARCH_FILTER to LDAP_SEARCH_FILTER_ADDITIONAL, don't add parentheses around it in code - making the configuration look more filter-like, e.g. (|(&(a=*)(b=*))(c=x));
  • avoid code repetition by setting variables and using those instead (as visible in e.g. Server/Connection object creation);
  • don't collate several Server/Connection calls in a single try - this will simplifiy debug logging (not included in this PR) and non-wrapping exception handling (if needed in the future);
  • some whitespace changes - purely cosmetic in function parameters, for consistent style;
  • bump version to 0.2.0;
  • reformat README.

Let me know if something needs clarification.

Fixes #37.

Independent of #46 (no merge conflict). Conflicts with #48 (see there).

veox added 12 commits November 29, 2016 22:30
It may be 'username', 'email' or any other LDAP attribute that
a search operation is performed with.
What's previously been called properties is properly called attributes:

https://www.ldap.com/glossary-of-ldap-terms

Replace this misnomer everywhere - in code and docs.

Squashed-in is a general reformatting and expansion of the README,
including mention of a previously-undocumented `LDAP_SEARCH_FILTER`
plugin configuration parameter.

Add a reminder to use `pip3` if necessary (happened previously:
`services` already expects this to be available, although still
under a misleading name of 'username'.
…BUTE` from `connector.login()`.

`username` is used to create a database entry.

Previously, this attribute would not be searched for if not
specified explicitly in `SEARCH_ATTRIBUTE`. If the latter
instead contained something like `mail` (which oftentimes
_can_ change), that would be fed to `services.ldap_register()`,
which would try to use it as a username.

Only being able to get `username` if it's searched for with
`SEARCH_ATTRIBUTE` is a bug.

This could have also resulted in a new Taiga/Django user being
created every time a LDAP user changes their e-mail address.

Login form in default theme `taiga` reads "Username or email".
These are also the two most common attributes being searched for.
Therefore remove `SEARCH_ATTRIBUTE`, search by `USERNAME_ATTRIBUTE`
and `EMAIL_ATTRIBUTE` instead.

Also removed `SEARCH_ATTRIBUTE_SUFFIX` (it was a workaround to
search by e-mail).

Squashed: renamed `SEARCH_FILTER` -> `SEARCH_FILTER_ADDITIONAL` to reflect
its purpose. Modified its syntax to require parentheses. Should allow
more complex filters without additional tech debt.

Squashed: don't mention password in error message (it hasn't been tried).
Attempting to upgrade locally. The backward-incompatible changes
warrant this.
…'s password.

This was a refactoring-introduced bug that prevented to log in any
user, because the service account's password was used instead.
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.

1 participant