Skip to content

Commit ce8a1a2

Browse files
committed
BUG#34556157: Kerberos authorization fails when using SSPI as security interface
Connector/Python does support Kerberos authentication via GSSAPI on POSIX-based systems and Windows, additionally via SSPI on this latter OS. Authentication via GSSAPI is working alright on Windows, however, it is failing via SSPI. With this patch, the issues is fixed by using Negotiate as security support provider (SSP) instead of Kerberos. Negotiate acts as an application layer between Security Support Provider Interface (SSPI) and the other SSPs. Currently, the Negotiate security package selects between Kerberos and NTLM. Negotiate selects Kerberos unless it cannot be used by one of the systems involved in the authentication or the calling application did not provide sufficient information to use Kerberos. For more information regarding Negotiate and Kerberos, and why calling Negotiate is prefer over calling Kerberos directly, refer to [1, 2]. [1] https://docs.microsoft.com/en-us/windows/win32/secauthn/microsoft-negotiate?source=recommendations [2] https://docs.microsoft.com/en-us/windows/win32/secauthn/microsoft-kerberos?source=recommendations Change-Id: I7315a74e7a57e3fc5199fddbcf31d8a4c0297a11
1 parent 8eca244 commit ce8a1a2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ v8.0.32
1313

1414
- WL#15348: Support MIT Kerberos library on Windows
1515
- WL#15036: Support for type hints
16+
- BUG#34556157: Kerberos authorization fails when using SSPI as security interface
1617

1718
v8.0.31
1819
=======

lib/mysql/connector/plugins/authentication_kerberos_client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,26 @@ def auth_response(self, auth_data: Optional[bytes] = None) -> Optional[bytes]:
397397
_LOGGER.debug("targetspn: %s", targetspn)
398398
_LOGGER.debug("_auth_info is None: %s", _auth_info is None)
399399

400+
# The Security Support Provider Interface (SSPI) is an interface
401+
# that allows us to choose from a set of SSPs available in the
402+
# system; the idea of SSPI is to keep interface consistent no
403+
# matter what back end (a.k.a., SSP) we choose.
404+
405+
# When using SSPI we should not use Kerberos directly as SSP,
406+
# as remarked in [2], but we can use it indirectly via another
407+
# SSP named Negotiate that acts as an application layer between
408+
# SSPI and the other SSPs [1].
409+
410+
# Negotiate can select between Kerberos and NTLM on the fly;
411+
# it chooses Kerberos unless it cannot be used by one of the
412+
# systems involved in the authentication or the calling
413+
# application did not provide sufficient information to use
414+
# Kerberos.
415+
416+
# [1] https://docs.microsoft.com/en-us/windows/win32/secauthn/microsoft-negotiate?source=recommendations
417+
# [2] https://docs.microsoft.com/en-us/windows/win32/secauthn/microsoft-kerberos?source=recommendations
400418
self.clientauth = sspi.ClientAuth(
401-
"Kerberos",
419+
"Negotiate",
402420
targetspn=targetspn,
403421
auth_info=_auth_info,
404422
scflags=sum(flags),

0 commit comments

Comments
 (0)