Skip to content

Commit e808c25

Browse files
isrgomeznmariz
authored andcommitted
WL14440: Support for authentication_kerberos_client authentication plugin
This worklog implements the authentication_kerberos_client authentication plugin in MySQL Connector/Python. With this implementation, applications and MySQL Servers can use the Kerberos authentication protocol to mutually authenticate users and MySQL services.
1 parent 85e7e9a commit e808c25

File tree

9 files changed

+948
-53
lines changed

9 files changed

+948
-53
lines changed

cpydist/__init__.py

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,35 +238,60 @@ def _copy_vendor_libraries(self):
238238
if self.with_mysql_capi:
239239
plugin_ext = "dll" if os.name == "nt" else "so"
240240
plugin_path = os.path.join(self.with_mysql_capi, "lib", "plugin")
241-
plugin_name = ("authentication_ldap_sasl_client.{}"
242-
"".format(plugin_ext))
243241

244-
self.log.debug("ldap plugin_path: '{}'".format(
245-
os.path.join(plugin_path, plugin_name)))
246-
if os.path.exists(os.path.join(plugin_path, plugin_name)):
242+
# authentication_ldap_sasl_client
243+
plugin_name = (
244+
"authentication_ldap_sasl_client.{}".format(plugin_ext)
245+
)
246+
plugin_full_path = os.path.join(plugin_path, plugin_name)
247+
self.log.debug("ldap plugin_path: '%s'", plugin_full_path)
248+
if os.path.exists(plugin_full_path):
247249
bundle_plugin_libs = True
248250
vendor_libs.append(
249-
(plugin_path, [plugin_name]))
251+
(plugin_path, [os.path.join("plugin", plugin_name)])
252+
)
250253

251254
if bundle_plugin_libs and os.name == "nt":
252255
sasl_libs_path = os.path.join(self.with_mysql_capi, "bin")
253256
sasl_plugin_libs = ["libsasl.dll", "saslSCRAM.dll",
254257
"libcrypto-1_1-x64.dll"]
255258
vendor_libs.append((sasl_libs_path, sasl_plugin_libs))
256259

260+
# authentication_kerberos_client
261+
plugin_name = (
262+
"authentication_kerberos_client.{}".format(plugin_ext)
263+
)
264+
plugin_full_path = os.path.join(plugin_path, plugin_name)
265+
self.log.debug("kerberos plugin_path: '%s'", plugin_full_path)
266+
if os.path.exists(plugin_full_path):
267+
bundle_plugin_libs = True
268+
vendor_libs.append(
269+
(plugin_path, [os.path.join("plugin", plugin_name)])
270+
)
271+
257272
if not vendor_libs:
258273
return
259274

275+
# mysql/vendor
260276
if not os.path.exists(self.vendor_folder):
261277
mkpath(os.path.join(os.getcwd(), self.vendor_folder))
262278

279+
# mysql/vendor/plugin
280+
if not os.path.exists(os.path.join(self.vendor_folder, "plugin")):
281+
mkpath(os.path.join(os.getcwd(), self.vendor_folder, "plugin"))
282+
283+
# mysql/vendor/private
284+
if not os.path.exists(os.path.join(self.vendor_folder, "private")):
285+
mkpath(os.path.join(os.getcwd(), self.vendor_folder, "private"))
286+
263287
# Copy vendor libraries to 'mysql/vendor' folder
264288
self.log.info("Copying vendor libraries")
265289
for src_folder, files in vendor_libs:
266290
self.log.info("Copying folder: %s", src_folder)
267-
for filename in files:
291+
for filepath in files:
292+
dst_folder, filename = os.path.split(filepath)
268293
src = os.path.join(src_folder, filename)
269-
dst = os.path.join(os.getcwd(), self.vendor_folder)
294+
dst = os.path.join(os.getcwd(), self.vendor_folder, dst_folder)
270295
self.log.info("copying %s -> %s", src, dst)
271296
shutil.copy(src, dst)
272297

@@ -295,7 +320,7 @@ def _copy_vendor_libraries(self):
295320
sasl_plugin_libs.append(os.path.basename(lib_path_entry))
296321
sasl_libs.append((sasl_libs_path, sasl_plugin_libs))
297322

298-
# Copy vendor libraries to 'mysql/vendor' folder
323+
# Copy vendor libraries to 'mysql/vendor/private' folder
299324
self.log.info("Copying vendor libraries")
300325
for src_folder, files in sasl_libs:
301326
self.log.info("Copying folder: %s", src_folder)
@@ -304,7 +329,11 @@ def _copy_vendor_libraries(self):
304329
if not os.path.exists(src):
305330
self.log.warn("Library not found: %s", src)
306331
continue
307-
dst = os.path.join(os.getcwd(), self.vendor_folder)
332+
dst = os.path.join(
333+
os.getcwd(),
334+
self.vendor_folder,
335+
"private"
336+
)
308337
self.log.info("copying %s -> %s", src, dst)
309338
shutil.copy(src, dst)
310339

@@ -335,10 +364,13 @@ def _copy_vendor_libraries(self):
335364

336365
sasl2_libs.append((sasl2_libs_path, sasl2_scram_libs))
337366

338-
if not os.path.exists(os.path.join(self.vendor_folder, "sasl2")):
339-
mkpath(os.path.join(os.getcwd(), self.vendor_folder, "sasl2"))
367+
sasl2_libs_private_path = os.path.join(
368+
self.vendor_folder, "private", "sasl2"
369+
)
370+
if not os.path.exists(sasl2_libs_private_path):
371+
mkpath(sasl2_libs_private_path)
340372

341-
# Copy vendor libraries to 'mysql/vendor/sasl2' folder
373+
# Copy vendor libraries to 'mysql/vendor/private/sasl2' folder
342374
self.log.info("Copying vendor libraries")
343375
for src_folder, files in sasl2_libs:
344376
self.log.info("Copying folder: %s", src_folder)
@@ -347,14 +379,18 @@ def _copy_vendor_libraries(self):
347379
if not os.path.exists(src):
348380
self.log.warning("Library not found: %s", src)
349381
continue
350-
dst = os.path.join(
351-
os.getcwd(),
352-
os.path.join(self.vendor_folder, "sasl2"))
382+
dst = os.path.join(os.getcwd(), sasl2_libs_private_path)
353383
self.log.info("copying %s -> %s", src, dst)
354384
shutil.copy(src, dst)
355385

356386
self.distribution.package_data = {
357-
"mysql": ["vendor/*", "vendor/sasl2/*"]}
387+
"mysql": [
388+
"vendor/*",
389+
"vendor/plugin/*",
390+
"vendor/private/*",
391+
"vendor/private/sasl2/*"
392+
]
393+
}
358394

359395

360396
class BuildExt(build_ext, BaseCommand):

0 commit comments

Comments
 (0)