myldapsync 1.0.7__tar.gz → 1.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of myldapsync might be problematic. Click here for more details.

Files changed (21) hide show
  1. {myldapsync-1.0.7/myldapsync.egg-info → myldapsync-1.0.9}/PKG-INFO +21 -3
  2. {myldapsync-1.0.7 → myldapsync-1.0.9}/README.md +19 -2
  3. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/__init__.py +18 -27
  4. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/ldaputils/connection.py +10 -16
  5. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/ldaputils/users.py +4 -5
  6. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/myutils/users.py +4 -6
  7. {myldapsync-1.0.7 → myldapsync-1.0.9/myldapsync.egg-info}/PKG-INFO +21 -3
  8. {myldapsync-1.0.7 → myldapsync-1.0.9}/setup.py +2 -1
  9. {myldapsync-1.0.7 → myldapsync-1.0.9}/LICENSE +0 -0
  10. {myldapsync-1.0.7 → myldapsync-1.0.9}/MANIFEST.in +0 -0
  11. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/config.ini.example +0 -0
  12. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/config_default.ini +0 -0
  13. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/ldaputils/__init__.py +0 -0
  14. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync/myutils/__init__.py +0 -0
  15. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync.egg-info/SOURCES.txt +0 -0
  16. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync.egg-info/dependency_links.txt +0 -0
  17. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync.egg-info/entry_points.txt +0 -0
  18. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync.egg-info/requires.txt +0 -0
  19. {myldapsync-1.0.7 → myldapsync-1.0.9}/myldapsync.egg-info/top_level.txt +0 -0
  20. {myldapsync-1.0.7 → myldapsync-1.0.9}/requirements.txt +0 -0
  21. {myldapsync-1.0.7 → myldapsync-1.0.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myldapsync
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: Synchronise LDAP users to MySQL and MariaDB
5
5
  Home-page: https://github.com/6eh01der/myldapsync
6
6
  Author: Artur Lebedev
@@ -8,7 +8,7 @@ Author-email: ras_atari@mail.ru
8
8
  License: MySQL
9
9
  Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB/pgldapsync) by [EnterpriseDB Corporation](https://www.enterprisedb.com/) adopted for MySQL and MariaDB
10
10
 
11
- This Python module allows you to synchronise MySQL or MariaDB users
11
+ This Python module allows you to synchronize MySQL or MariaDB users
12
12
  with users in an LDAP directory.
13
13
 
14
14
  Require MySQL 8 with installed and configured simple or sasl LDAP Authentication Plugin or PAM plugin (pam also supported in MySQL 5.7 and MariaDB).
@@ -50,7 +50,7 @@ Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB
50
50
 
51
51
  python3 -m venv /path/to/myldapsync
52
52
  source /path/to/myldapsync/bin/activate
53
- pip install -r requirements.txt
53
+ pip install -r /path/to/myldapsync/requirements.txt
54
54
 
55
55
  Adapt the first command as required for your environment/Python
56
56
  version.
@@ -60,8 +60,25 @@ Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB
60
60
  To create a package (wheel), run the following in your virtual
61
61
  environment:
62
62
 
63
+ cd /path/to/myldapsync
64
+ pip install wheel
63
65
  python3 setup.py sdist bdist_wheel
64
66
 
67
+ ## Installation from [PyPI](https://pypi.org/project/myldapsync/)
68
+
69
+ Via pip:
70
+ ```
71
+ pip install myldapsync
72
+ ```
73
+ Via pipx:
74
+ ```
75
+ pipx install myldapsync
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ Example with some annotations - https://github.com/6eh01der/myldapsync/blob/main/myldapsync/config.ini.example
81
+
65
82
  Platform: UNKNOWN
66
83
  Classifier: Programming Language :: Python :: 3
67
84
  Classifier: Programming Language :: Python :: 3.8
@@ -69,6 +86,7 @@ Classifier: Programming Language :: Python :: 3.9
69
86
  Classifier: Programming Language :: Python :: 3.10
70
87
  Classifier: Programming Language :: Python :: 3.11
71
88
  Classifier: Programming Language :: Python :: 3.12
89
+ Classifier: Programming Language :: Python :: 3.13
72
90
  Classifier: License :: OSI Approved :: GNU General Public License (GPL)
73
91
  Classifier: Operating System :: OS Independent
74
92
  Requires-Python: >=3.8
@@ -1,6 +1,6 @@
1
1
  # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB/pgldapsync) by [EnterpriseDB Corporation](https://www.enterprisedb.com/) adopted for MySQL and MariaDB
2
2
 
3
- This Python module allows you to synchronise MySQL or MariaDB users
3
+ This Python module allows you to synchronize MySQL or MariaDB users
4
4
  with users in an LDAP directory.
5
5
 
6
6
  Require MySQL 8 with installed and configured simple or sasl LDAP Authentication Plugin or PAM plugin (pam also supported in MySQL 5.7 and MariaDB).
@@ -42,7 +42,7 @@ be executed to stdout), run it like this:
42
42
 
43
43
  python3 -m venv /path/to/myldapsync
44
44
  source /path/to/myldapsync/bin/activate
45
- pip install -r requirements.txt
45
+ pip install -r /path/to/myldapsync/requirements.txt
46
46
 
47
47
  Adapt the first command as required for your environment/Python
48
48
  version.
@@ -52,4 +52,21 @@ version.
52
52
  To create a package (wheel), run the following in your virtual
53
53
  environment:
54
54
 
55
+ cd /path/to/myldapsync
56
+ pip install wheel
55
57
  python3 setup.py sdist bdist_wheel
58
+
59
+ ## Installation from [PyPI](https://pypi.org/project/myldapsync/)
60
+
61
+ Via pip:
62
+ ```
63
+ pip install myldapsync
64
+ ```
65
+ Via pipx:
66
+ ```
67
+ pipx install myldapsync
68
+ ```
69
+
70
+ ## Configuration
71
+
72
+ Example with some annotations - https://github.com/6eh01der/myldapsync/blob/main/myldapsync/config.ini.example
@@ -59,17 +59,13 @@ def read_config(file):
59
59
  try:
60
60
  config.read(defaults)
61
61
  except configparser.Error as exception:
62
- sys.stderr.write(
63
- "Error reading default configuration file (%s): %s\n" %
64
- (defaults, exception))
62
+ sys.stderr.write(f"Error reading default configuration file ({defaults}): {exception}\n")
65
63
  sys.exit(1)
66
64
 
67
65
  try:
68
66
  config.read(file)
69
67
  except configparser.Error as exception:
70
- sys.stderr.write(
71
- "Error reading user configuration file (%s): %s\n" %
72
- (file, exception))
68
+ sys.stderr.write(f"Error reading user configuration file ({file}): {exception}\n")
73
69
  sys.exit(1)
74
70
 
75
71
  return config
@@ -184,8 +180,8 @@ def main():
184
180
  cur.execute("START TRANSACTION;")
185
181
 
186
182
  # Set authentication plugin
187
- identified = ''
188
183
  if (auth_plugin := config.get('general', 'auth_plugin')) != '':
184
+ identified = ''
189
185
  if auth_plugin == 'simple':
190
186
  identified = 'WITH authentication_ldap_simple'
191
187
  elif auth_plugin == 'sasl':
@@ -220,8 +216,8 @@ def main():
220
216
  if args.dry_run:
221
217
 
222
218
  # It's a dry run, so just print the output
223
- print('CREATE USER "%s" IDENTIFIED %s; %s %s %s' %
224
- (user_name, identified, privilege_list, user_grants, user_admin_grants))
219
+ print(f'CREATE USER "{user_name}" IDENTIFIED {identified};\
220
+ {privilege_list} {user_grants} {user_admin_grants}')
225
221
  else:
226
222
 
227
223
  # This is a live run, so directly execute the SQL generated.
@@ -231,19 +227,17 @@ def main():
231
227
  try:
232
228
  # We can't use a real parameterised query here as we're
233
229
  # working with an object, not data.
234
- cur.execute('CREATE USER "%s" IDENTIFIED %s;' %
235
- (user_name, identified))
236
- cur.execute('%s' % privilege_list)
237
- cur.execute('%s' % user_grants)
238
- cur.execute('%s' % user_admin_grants)
230
+ cur.execute(f'CREATE USER "{user_name}" IDENTIFIED {identified};')
231
+ cur.execute(f'{privilege_list}')
232
+ cur.execute(f'{user_grants}')
233
+ cur.execute(f'{user_admin_grants}')
239
234
  if (filter_string := config.get('mysql', 'filter_string')) != '' and \
240
235
  ("(objectClass=group)" in filter_string or \
241
236
  "(objectClass=groupOfNames)" in filter_string):
242
- cur.execute('GRANT PROXY ON "%s" TO ''@'';' % user_name)
237
+ cur.execute(f'GRANT PROXY ON "{user_name}" TO ''@'';')
243
238
  users_added = users_added + 1
244
239
  except mysql.connector.Error as exception:
245
- sys.stderr.write("Error creating user %s: %s" % (user,
246
- exception))
240
+ sys.stderr.write(f"Error creating user {user}: {exception}")
247
241
  users_add_errors = users_add_errors + 1
248
242
  cur.execute('ROLLBACK;')
249
243
 
@@ -258,7 +252,7 @@ def main():
258
252
  if args.dry_run:
259
253
 
260
254
  # It's a dry run, so just print the output
261
- print('DROP USER "%s";' % user_name)
255
+ print(f'DROP USER "{user_name}";')
262
256
  else:
263
257
 
264
258
  # This is a live run, so directly execute the SQL generated.
@@ -268,11 +262,10 @@ def main():
268
262
  try:
269
263
  # We can't use a real parameterised query here as we're
270
264
  # working with an object, not data.
271
- cur.execute('DROP USER "%s";' % user_name)
265
+ cur.execute(f'DROP USER "{user_name}";')
272
266
  users_dropped = users_dropped + 1
273
267
  except mysql.connector.Error as exception:
274
- sys.stderr.write("Error dropping user %s: %s" % (user,
275
- exception))
268
+ sys.stderr.write(f"Error dropping user {user}: {exception}")
276
269
  users_drop_errors = users_drop_errors + 1
277
270
  cur.execute('ROLLBACK;')
278
271
 
@@ -286,13 +279,11 @@ def main():
286
279
  cur.close()
287
280
 
288
281
  # Print the summary of work completed
289
- print("Users added to MySQL: %d" % users_added)
290
- print("Users dropped from MySQL: %d" % users_dropped)
282
+ print(f"Users added to MySQL: {users_added}")
283
+ print(f"Users dropped from MySQL: {users_dropped}")
291
284
  if users_add_errors > 0:
292
- print("Errors adding users: %d" %
293
- users_add_errors)
285
+ print(f"Errors adding users: {users_add_errors}")
294
286
  if users_drop_errors > 0:
295
- print("Errors dropping users: %d" %
296
- users_drop_errors)
287
+ print(f"Errors dropping users: {users_drop_errors}")
297
288
  else:
298
289
  print("No users were added or dropped.")
@@ -66,7 +66,7 @@ def connect_ldap_server(config):
66
66
 
67
67
  # Debug
68
68
  if config.getboolean('ldap', 'debug'):
69
- sys.stderr.write("TLS/SSL configuration: %s\n" % tls)
69
+ sys.stderr.write(f"TLS/SSL configuration: {tls}\n")
70
70
 
71
71
  # Create the server object
72
72
  server = Server(uri.hostname,
@@ -76,7 +76,7 @@ def connect_ldap_server(config):
76
76
 
77
77
  # Debug
78
78
  if config.getboolean('ldap', 'debug'):
79
- sys.stderr.write("LDAP server config: %s\n" % server)
79
+ sys.stderr.write(f"LDAP server config: {server}\n")
80
80
 
81
81
  # Create the connection
82
82
  conn = None
@@ -96,34 +96,28 @@ def connect_ldap_server(config):
96
96
  config.get('ldap', 'bind_password'),
97
97
  auto_bind=True)
98
98
  except LDAPSocketOpenError as exception:
99
- sys.stderr.write("Error connecting to the LDAP server: %s\n" %
100
- exception)
99
+ sys.stderr.write(f"Error connecting to the LDAP server: {exception}\n")
101
100
  except LDAPBindError as exception:
102
- sys.stderr.write("Error binding to the LDAP server: %s\n" % exception)
103
-
101
+ sys.stderr.write(f"Error binding to the LDAP server: {exception}\n")
104
102
  except LDAPSASLBindInProgressError as exception:
105
- sys.stderr.write("SASL bind in progress error: %s\n" % exception)
106
-
103
+ sys.stderr.write(f"SASL bind in progress error: {exception}\n")
107
104
  except LDAPSASLPrepError as exception:
108
- sys.stderr.write("SASL prep error: %s\n" % exception)
109
-
105
+ sys.stderr.write(f"SASL prep error: {exception}\n")
110
106
  except LDAPSASLMechanismNotSupportedError as exception:
111
- sys.stderr.write("SASL mechanism not supported error: %s\n" % exception)
112
-
107
+ sys.stderr.write(f"SASL mechanism not supported error: {exception}\n")
113
108
  # Debug
114
109
  if config.getboolean('ldap', 'debug'):
115
- sys.stderr.write("Initial LDAP connection: %s\n" % conn)
116
-
110
+ sys.stderr.write(f"Initial LDAP connection: {conn}\n")
117
111
  # Enable TLS if STARTTLS is configured
118
112
  if uri.scheme != 'ldaps' and config.getboolean('ldap', 'use_starttls'):
119
113
  try:
120
114
  conn.start_tls()
121
115
  except LDAPStartTLSError as exception:
122
- sys.stderr.write("Error starting TLS: %s\n" % exception)
116
+ sys.stderr.write(f"Error starting TLS: {exception}\n")
123
117
  return None
124
118
 
125
119
  # Debug
126
120
  if config.getboolean('ldap', 'debug'):
127
- sys.stderr.write("Final LDAP connection: %s\n" % conn)
121
+ sys.stderr.write(f"Final LDAP connection: {conn}\n")
128
122
 
129
123
  return conn
@@ -40,13 +40,13 @@ def get_ldap_users(config, conn, admin):
40
40
  attributes=[config.get('ldap', 'username_attribute')]
41
41
  )
42
42
  except LDAPInvalidScopeError as exception:
43
- sys.stderr.write("Error searching the LDAP directory: %s\n" % exception)
43
+ sys.stderr.write(f"Error searching the LDAP directory: {exception}\n")
44
44
  sys.exit(1)
45
45
  except LDAPAttributeError as exception:
46
- sys.stderr.write("Error searching the LDAP directory: %s\n" % exception)
46
+ sys.stderr.write(f"Error searching the LDAP directory: {exception}\n")
47
47
  sys.exit(1)
48
48
  except LDAPInvalidFilterError as exception:
49
- sys.stderr.write("Error searching the LDAP directory: %s\n" % exception)
49
+ sys.stderr.write(f"Error searching the LDAP directory: {exception}\n")
50
50
  sys.exit(1)
51
51
 
52
52
  for entry in conn.entries:
@@ -66,8 +66,7 @@ def get_filtered_ldap_users(config, conn, admin):
66
66
  Returns:
67
67
  str[]: A filtered list of user names
68
68
  """
69
- users = get_ldap_users(config, conn, admin)
70
- if users is None:
69
+ if (users := get_ldap_users(config, conn, admin)) is None:
71
70
  return None
72
71
 
73
72
  # Remove ignored users
@@ -30,8 +30,7 @@ def get_my_users(conn):
30
30
  "AND authentication_string IS NOT NULL;")
31
31
  rows = cur.fetchall()
32
32
  except mysql.connector.Error as exception:
33
- sys.stderr.write("Error retrieving MySQL users: %s\n" %
34
- exception)
33
+ sys.stderr.write(f"Error retrieving MySQL users: {exception}\n")
35
34
  return None
36
35
 
37
36
  users = []
@@ -54,8 +53,7 @@ def get_filtered_my_users(config, conn):
54
53
  Returns:
55
54
  str[]: A filtered list of users
56
55
  """
57
- users = get_my_users(conn)
58
- if users is None:
56
+ if (users := get_my_users(conn)) is None:
59
57
  return None
60
58
 
61
59
  # Remove ignored users
@@ -131,7 +129,7 @@ def get_user_privileges(config, user, with_grant=False):
131
129
  privilege_list = privilege_list[:-2]
132
130
 
133
131
  if privilege_list != '':
134
- sql = 'GRANT %s ON %s.* TO "%s"' % (privilege_list, database, user)
132
+ sql = f'GRANT {privilege_list} ON {database}.* TO "{user}"'
135
133
  if with_grant:
136
134
  sql = sql + " WITH GRANT OPTION"
137
135
  sql = sql + ';'
@@ -168,7 +166,7 @@ def get_user_grants(config, user, with_admin=False):
168
166
  roles = roles[:-2]
169
167
 
170
168
  if roles != '':
171
- sql = 'GRANT %s TO "%s"' % (roles, user)
169
+ sql = f'GRANT {roles} TO "{user}"'
172
170
 
173
171
  if with_admin:
174
172
  sql = sql + " WITH ADMIN OPTION"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: myldapsync
3
- Version: 1.0.7
3
+ Version: 1.0.9
4
4
  Summary: Synchronise LDAP users to MySQL and MariaDB
5
5
  Home-page: https://github.com/6eh01der/myldapsync
6
6
  Author: Artur Lebedev
@@ -8,7 +8,7 @@ Author-email: ras_atari@mail.ru
8
8
  License: MySQL
9
9
  Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB/pgldapsync) by [EnterpriseDB Corporation](https://www.enterprisedb.com/) adopted for MySQL and MariaDB
10
10
 
11
- This Python module allows you to synchronise MySQL or MariaDB users
11
+ This Python module allows you to synchronize MySQL or MariaDB users
12
12
  with users in an LDAP directory.
13
13
 
14
14
  Require MySQL 8 with installed and configured simple or sasl LDAP Authentication Plugin or PAM plugin (pam also supported in MySQL 5.7 and MariaDB).
@@ -50,7 +50,7 @@ Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB
50
50
 
51
51
  python3 -m venv /path/to/myldapsync
52
52
  source /path/to/myldapsync/bin/activate
53
- pip install -r requirements.txt
53
+ pip install -r /path/to/myldapsync/requirements.txt
54
54
 
55
55
  Adapt the first command as required for your environment/Python
56
56
  version.
@@ -60,8 +60,25 @@ Description: # myldapsync - fork of [pgldapsync](https://github.com/EnterpriseDB
60
60
  To create a package (wheel), run the following in your virtual
61
61
  environment:
62
62
 
63
+ cd /path/to/myldapsync
64
+ pip install wheel
63
65
  python3 setup.py sdist bdist_wheel
64
66
 
67
+ ## Installation from [PyPI](https://pypi.org/project/myldapsync/)
68
+
69
+ Via pip:
70
+ ```
71
+ pip install myldapsync
72
+ ```
73
+ Via pipx:
74
+ ```
75
+ pipx install myldapsync
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ Example with some annotations - https://github.com/6eh01der/myldapsync/blob/main/myldapsync/config.ini.example
81
+
65
82
  Platform: UNKNOWN
66
83
  Classifier: Programming Language :: Python :: 3
67
84
  Classifier: Programming Language :: Python :: 3.8
@@ -69,6 +86,7 @@ Classifier: Programming Language :: Python :: 3.9
69
86
  Classifier: Programming Language :: Python :: 3.10
70
87
  Classifier: Programming Language :: Python :: 3.11
71
88
  Classifier: Programming Language :: Python :: 3.12
89
+ Classifier: Programming Language :: Python :: 3.13
72
90
  Classifier: License :: OSI Approved :: GNU General Public License (GPL)
73
91
  Classifier: Operating System :: OS Independent
74
92
  Requires-Python: >=3.8
@@ -19,7 +19,7 @@ with open('README.md', 'r', encoding='utf-8') as fh:
19
19
 
20
20
  setuptools.setup(
21
21
  name="myldapsync",
22
- version="1.0.7",
22
+ version="1.0.9",
23
23
  author="Artur Lebedev",
24
24
  author_email="ras_atari@mail.ru",
25
25
  description="Synchronise LDAP users to MySQL and MariaDB",
@@ -37,6 +37,7 @@ setuptools.setup(
37
37
  'Programming Language :: Python :: 3.10',
38
38
  'Programming Language :: Python :: 3.11',
39
39
  'Programming Language :: Python :: 3.12',
40
+ 'Programming Language :: Python :: 3.13',
40
41
  "License :: OSI Approved :: GNU General Public License (GPL)",
41
42
  "Operating System :: OS Independent",
42
43
  ],
File without changes
File without changes
File without changes
File without changes