Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ntlm-sspi #67

Closed
wants to merge 2 commits into from
Closed

Ntlm-sspi #67

wants to merge 2 commits into from

Conversation

vmuriart
Copy link

Perform ntlm authentication through sspi for windows users. Enables user to authenticate without having to type un/pw.
Also for troubleshooting #65.
Based on pr #41

added to perform ntlm auth using sspi to enable passwordless login.
@vmuriart
Copy link
Author

Concerning if this should be its own package.
This is analogous to requests-kerberos where they implement both kerberos through both the kerberos library and through sspi.

@@ -1,3 +1,3 @@
from .requests_ntlm import HttpNtlmAuth
from .requests_ntlm import HttpNtlmAuth, HttpNtlmSspiAuth

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid import error should be:

from .requests_ntlm import HttpNtlmAuth
from .requests_ntlmsspi import HttpNtlmSspiAuth

@vmuriart vmuriart closed this Mar 27, 2016
@blah238
Copy link

blah238 commented May 10, 2016

@vmuriart Why was this closed?

@vmuriart
Copy link
Author

was going to release it independently; and forgot...

@ChrisKnott
Copy link

@vmuriart I'm having trouble getting this working with Python 3.5, do you happen to have a version that works?

@vmuriart
Copy link
Author

Haven't tried it myself on 3.5. I'll take a look over the weekend and let
you know. Any chance you can post the error you are getting ?

On Thursday, July 28, 2016, Chris Knott [email protected] wrote:

@vmuriart https://github.com/vmuriart I'm having trouble getting this
working with Python 3.5, do you happen to have a version that works?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#67 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMr87IjL-A0Wj4LyWQLk67B2oj0Kpxwbks5qaOjHgaJpZM4HP1-v
.

@ChrisKnott
Copy link

I think it's just due to py3's stupid string encoding stuff, but I thought I patched everything up, it's now complaining outside of your code, in http client.

File "c:\Users\Chris\Documents\reqsspi.py", line 26, in response_hook return self.apply_sspi('www-authenticate', 'Authorization', r, kwargs) File "c:\Users\Chris\Documents\reqsspi.py", line 84, in apply_sspi return response.connection.send(request, **args) File "C:\Program Files\Python35\lib\site-packages\requests\adapters.py", line 403, in send timeout=timeout File "C:\Program Files\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 578, in urlopen chunked=chunked) File "C:\Program Files\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 362, in _make_request conn.request(method, url, **httplib_request_kw) File "C:\Program Files\Python35\lib\http\client.py", line 1106, in request self._send_request(method, url, body, headers) File "C:\Program Files\Python35\lib\http\client.py", line 1146, in _send_request self.putheader(hdr, value) File "C:\Program Files\Python35\lib\http\client.py", line 1082, in putheader if _is_illegal_header_value(values[i]): TypeError: expected string or bytes-like object

@vmuriart
Copy link
Author

Hmm. Curious. Do you have a fork with your changes so I have a starting
point in case I come across the same encoding issues?

On Thursday, July 28, 2016, Chris Knott [email protected] wrote:

I think it's just due to py3's stupid string encoding stuff, but I thought
I patched everything up, it's now complaining outside of your code, in http
client.

File "c:\Users\Chris\Documents\reqsspi.py", line 26, in response_hook
return self.apply_sspi('www-authenticate', 'Authorization', r, kwargs)
File "c:\Users\Chris\Documents\reqsspi.py", line 84, in apply_sspi
return response.connection.send(request, *_args)
File "C:\Program Files\Python35\lib\site-packages\requests\adapters.py",
line 403, in send
timeout=timeout
File "C:\Program
Files\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py",
line 578, in urlopen
chunked=chunked)
File "C:\Program
Files\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py",
line 362, in _make_request
conn.request(method, url, *_httplib_request_kw)
File "C:\Program Files\Python35\lib\http\client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "C:\Program Files\Python35\lib\http\client.py", line 1146, in
_send_request
self.putheader(hdr, value)
File "C:\Program Files\Python35\lib\http\client.py", line 1082, in
putheader
if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#67 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMr87HfIuB5AfslIHp81kp84txtS4NW1ks5qaOnCgaJpZM4HP1-v
.

@ChrisKnott
Copy link

ChrisKnott commented Jul 28, 2016

I just changed this line (line 51)...

return 'NTLM %s' % base64.b64encode(output_buffer[0].Buffer).decode('utf-8').replace('\n', '')

@ChrisKnott
Copy link

ChrisKnott commented Jul 28, 2016

Ok, got it working.

My change is fine for py3. The issue is this line which just happened to break on my service...
request.headers['Cookie'] = response.headers.get('set-cookie')

Headers cannot be None else they break here - _is_illegal_header_value(values[i]): - in client.py

@brandond
Copy link

brandond commented Aug 5, 2016

FWIW, I just published a module that supports pass-through auth via SSPI using either NTLM or Kerberos by way of the Negotiate method.

https://github.com/brandond/requests-negotiate-sspi

@kevinp2
Copy link

kevinp2 commented Jan 10, 2022

Was this ever resolved? It would be really very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants