1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-06-13 14:19:51 +02:00
Commit Graph

73 Commits

Author SHA1 Message Date
Christian Connert
21c8438587 Revert "read credentials from environment variables"
This reverts commit 7af125550c.
2019-07-09 15:19:14 +02:00
Christian Connert
b6cba42b85 Added checks to avoid unnecessary updates when the attribute did not change and extended delete to remove user from groups 2019-07-09 15:14:42 +02:00
Kevin Li
7af125550c read credentials from environment variables 2019-05-23 12:41:41 +08:00
kakwa
882a303474 fix crash due to encoding in python 2 2019-02-12 23:27:30 +01:00
kakwa
7ac7118c9a adding a debug log to help figure out issues with filters. 2019-02-12 22:43:03 +01:00
kakwa
02357d886a remove debug print 2019-02-09 18:18:58 +01:00
kakwa
baa3430e63 fix test and exception handling in code
With python 2 it was possible to do exception[0][...] to recover
details about an exception.
It's no longer authorized with python 3.
Now, we must do something like exception.args or exception.urls.
fortunately this syntax also works with python 2.
So we use it for both.
2019-02-09 17:12:39 +01:00
kakwa
10747cff93 add some python 3 support in the LDAP and AD backends
python-ldap talks in bytes,
as the rest of ldapcherry talks in unicode utf-8:
* everything passed to python-ldap must be converted to bytes
* everything coming from python-ldap must be converted to unicode

The previous statement was true for python-ldap < version 3.X.
With versions > 3.0.0 and python 3, it gets tricky,
some parts of python-ldap takes string, specially the filters/escaper.

so we have now:
*_byte_p2 (unicode -> bytes conversion for python 2)
*_byte_p3 (unicode -> bytes conversion for python 3)
*_byte_p23 (unicode -> bytes conversion for python AND 3)
2019-02-09 16:08:18 +01:00
kakwa
bbfe96d4f7 pep8 2019-02-09 12:05:09 +01:00
kakwa
b9437abefb * support for python-ldap 2 and 3
* python-ldap 3 is slightly different than 2 on how it handles modify
the modified attributes used to be transmitted as a dict, now it should
be transmitted as a list of dict)
2019-02-09 11:58:09 +01:00
kakwa
42759f1cc4 pep8 2019-02-08 20:38:03 +01:00
kakwa
18fdeb483e better handling of the str/byte mess for python3
* add dedicated methods for python 3 in handling of bytearrays/strings
* using them to compare attributes checks in AD backend
2019-02-08 20:33:58 +01:00
kakwa
3d6e24eb73 pep8 2019-02-07 20:16:39 +01:00
kakwa
74dc6c5894 various changes to support python3
* changes in urllib imports since quote_plus in urllib with python 2 and
in urllib.parse in python 3
* changes in imports for Sets since set is a native type in python 3 and
doesn't requires an import
* fix in __import__, '-1' level for module path discovery is not supported
anymore, switching to 0 (absolute import only).
2019-02-06 22:32:40 +01:00
kakwa
eb36830845 fixes 2017-03-16 03:03:59 +01:00
kakwa
3fd6dcee82 fix issue related to python-ldap returning lists
Before, no particular treatment was done on the user attributes.
This caused some issues because python-ldap systematically returns
the attribute value as a list (even if it's mono-valuated).

Now we recover the attributes used in the group attr templates,
and we "normalize" the user attributes before using it in add_to_groups
and del_from_groups.

By normalize, we mean, transforming the list to it's unique value.
In case the attribute doesn't exist or is multi-valuated, it raises an
error.
2017-03-16 02:45:23 +01:00
kakwa
5a45a24055 proper exception in ldap backend
adding proper management of none existant user in group function
if user doesn't exist.
2016-08-01 19:57:51 +02:00
kakwa
7f00264e32 improve robustness if user dn attribute contains something like ,cn= 2016-07-31 12:21:26 +02:00
kakwa
d4235bc33c better behavior if user doesn't exist in one backend 2016-07-31 11:39:28 +02:00
kakwa
6c3fb4975d fix many encoding errors on login and password 2016-07-07 20:22:33 +02:00
kakwa
b8a65a44b6 pepify the source code 2016-06-17 00:10:02 +02:00
kakwa
c969e730c4 fix password setting with Active Directory 2016-06-16 21:49:48 +02:00
kakwa
4e5c361e5e fix error messages/logs in ldap backend 2015-11-03 08:53:46 +01:00
kakwa
a8af29692e custom error handling for UserDoesntExist, UserAlreadyExists and GroupDoesntExist 2015-07-31 22:43:51 +02:00
kakwa
efcaad54fc multiple modification/fix
* add display_name parameter for backend
* handle display_name in modify template (lonely groups) and error
  message
* fix bug in modify when user is in only one backend
* remove redondant exception in ad/ldap backend
* fix unit test accordingly
* fix License in AD backend (GPLv3 -> MIT, previously tought of using
  samba4 python library which is GPL, but this module finaly uses
  python-ldap which is MIT compatible)
2015-07-31 20:08:21 +02:00
kakwa
6ee0ff0354 many comment + encoding fixes 2015-07-29 08:15:54 +02:00
kakwa
ff08e09598 more encoding error fix (on ldap auth) 2015-07-29 00:14:49 +02:00
kakwa
69700d0ce9 more encoding fixes 2015-07-29 00:09:15 +02:00
kakwa
3391ed9704 fix more encoding error 2015-07-28 23:57:14 +02:00
kakwa
9ec7a3dfbe fix rename in modify
when renaming an entry, dn must be reset to the correct value for
the modifications that come after the rename.
2015-07-28 23:38:29 +02:00
kakwa
f2c1a6af44 many fixes in encoding handling 2015-07-28 23:27:02 +02:00
kakwa
4e5591db7a fix encoding error on dn 2015-07-28 22:18:57 +02:00
kakwa
27fca43ac6 Better exception re-raising
re-raising the exception without specifying the exception object gives
exactly the previous exception (including the correct stacktrace)
which is nicer to have for debugging.
2015-07-28 20:30:51 +02:00
kakwa
e3fe0b4bfb implementing renaming entry 2015-07-28 00:18:05 +02:00
kakwa
64b9573634 escaping search string for ldap 2015-07-15 21:28:54 +02:00
kakwa
3a6da2e480 better exception handling if user or group doesn't exist 2015-07-15 21:05:38 +02:00
kakwa
1885079444 pep8 compliance 2015-07-11 22:25:21 +02:00
kakwa
3712bb85cb many pep8 fixes thanks to pep8ify 2015-07-10 21:06:28 +02:00
kakwa
df88f2f266 remove trailing spaces 2015-07-05 22:48:24 +02:00
kakwa
e9d5331d6a various fix on ssl/tls + tests
* making ssl cert check and cert no check works
* adding a test to check if the cafile does exist
* reenable and fix ssl checks on travis
2015-07-05 22:01:09 +02:00
kakwa
373d897cab better exception handling in ldap backend 2015-06-28 19:54:19 +02:00
kakwa
147cad3511 fix unicode 2015-06-27 22:35:34 +02:00
kakwa
f821aab9f4 adding logs when adding a user to a group 2015-06-18 20:38:10 +02:00
kakwa
c2288eecf5 fix unit test and fix the way ldap connexion options are handled 2015-06-17 19:22:57 +02:00
kakwa
0d766d3303 fix add/del groups 2015-06-16 23:56:12 +02:00
kakwa
60a7329937 fix API for backend ldap on groups handling 2015-06-16 21:58:44 +02:00
kakwa
a2fe74539b multiple modification in backend ldap
* better handling of which attributes is recovered
* fix set_attrs method
* change api of set_attrs method for constancy
* change calls to _get_user and _search methods (internal api change)
2015-06-16 21:29:40 +02:00
kakwa
4a302750c0 implementing modify and add/rm to groups 2015-06-14 20:55:23 +02:00
kakwa
247a1fed3a removing trailling spaces 2015-06-06 22:23:21 +02:00
kakwa
c9b971e8b0 adding key handling 2015-05-31 18:40:35 +02:00