Skip to content

Commit e25a4fe

Browse files
authored
Merge pull request #20 from michael-o/sane-flags
Pass sane flags to security context
2 parents f019c68 + 3e30f9f commit e25a4fe

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

requests_negotiate_sspi/requests_negotiate_sspi.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@ def _retry_using_http_Negotiate_auth(self, response, scheme, args):
7373

7474
targetspn = '{}/{}'.format(self._service, self._host)
7575

76+
# We request mutual auth by default
77+
scflags = sspicon.ISC_REQ_MUTUAL_AUTH
78+
79+
if self._delegate:
80+
scflags |= sspicon.ISC_REQ_DELEGATE
81+
7682
# Set up SSPI connection structure
7783
pkg_info = win32security.QuerySecurityPackageInfo(scheme)
78-
clientauth = sspi.ClientAuth(scheme, targetspn=targetspn, auth_info=self._auth_info)
84+
clientauth = sspi.ClientAuth(scheme, targetspn=targetspn, auth_info=self._auth_info,
85+
scflags=scflags, datarep=sspicon.SECURITY_NETWORK_DREP)
7986
sec_buffer = win32security.PySecBufferDescType()
8087

81-
# Calling sspi.ClientAuth with scflags set requires you to specify all the flags, including defaults.
82-
# We just want to add ISC_REQ_DELEGATE.
83-
if self._delegate:
84-
clientauth.scflags |= sspicon.ISC_REQ_DELEGATE
85-
8688
# Channel Binding Hash (aka Extended Protection for Authentication)
8789
# If this is a SSL connection, we need to hash the peer certificate, prepend the RFC5929 channel binding type,
8890
# and stuff it into a SEC_CHANNEL_BINDINGS structure.

0 commit comments

Comments
 (0)