Commit Graph

115 Commits

Author SHA1 Message Date
David Poole 1dbaddd75e for RFC-7616 add SHA-256 and SHA-512 2017-11-08 18:32:59 -07:00
kennethreitz 5fa4e74d61 fix flake8 indent error 2017-05-29 22:43:12 -04:00
kennethreitz 7f14db17c8 new requests namespace 2017-05-29 12:11:43 -04:00
Chris Gavin 19ba9f1097 Remove some unused imports. 2017-04-25 22:10:01 +01:00
Matthew Medal 8a58427d8a Only send HTTPDigestAuth on 4xx challenges
Resolves: #3772
2017-01-27 12:56:50 -08:00
kennethreitz 789f21807d python 2.6 compatibiliby 2016-12-20 13:16:14 -05:00
Ian Cordasco fae6701478 Add deprecation warnings for 3.0
Add extra test parameter for basic auth encoding
2016-12-09 08:43:54 -06:00
Nate Prewitt 576b447a37 adding string casting for non-bytes values 2016-12-08 21:13:14 -07:00
Dmitry Klimenko 2185fac626 remove extra import 2016-11-17 19:52:13 +03:00
Dmitry Klimenko 329a5cfdd4 Order of type check 2016-11-17 19:50:53 +03:00
Dmitry Klimenko e514920e19 Unable unicode in basic http auth
Fixed the issue with unicode characters in basic http auth
2016-11-12 01:39:37 +03:00
Brian Bamsch 087aeacee5 Change module of internal references to to_native_str() 2016-09-27 20:41:21 -07:00
Ville Skyttä 542fbbc67f Document bunch of return types 2016-08-09 13:32:56 +03:00
Nate Prewitt 2d4a89f5dc adding in pep8 fixes 2016-07-20 10:30:08 -06:00
Mark Shannon abe02ed89f Initialize hash_utf8 to None, preventing NameError. Fixes #3138. 2016-04-29 16:49:24 +01:00
Markus Unterwaditzer 2140c98fa4 Fix syntax error 2016-01-30 19:59:58 +01:00
kennethreitz 6195edc075 cleanup of auth __eq__ 2016-01-29 22:18:07 -05:00
Nicolas Delvaux 06df08e676 Add equality functions for authentication handlers 2016-01-04 17:01:06 +01:00
Matt Jordan 5c19d3e07b requests/auth: Handle an empty 'qop' attribute in a Authenticate challenge
Some malfunctioning HTTP servers may return a qop directive with no token, as
opposed to correctly omitting the qop directive completely. For example:

header: WWW-Authenticate: Digest realm="foobar_api_auth", qop="",
        nonce="a12059eaaad0b86ece8f62f04cbafed6", algorithm="MD5",
        stale="false"

Prior to this patch, requests would respond with a 'None' Authorization header.
While the server is certainly incorrect, this patch updates requests to be
more tolerant to this kind of shenaniganry. If we receive an empty string for
the value of the qop attribute, we instead treat that as if the qop attribute
was simply not provided.

Closes #2916
2015-12-05 16:14:52 -06:00
Ian Cordasco 77d7e53c12 Merge branch 'auth-digest-multi-thread' of https://github.com/exvito/requests into proposed/2.8.0 2015-07-18 10:38:58 -05:00
Saimadhav Heblikar 86aff09103 Auth handler calls close instead of raw.close_conn 2015-05-14 11:42:07 +05:30
Ian Cordasco 956ec8321a Merge pull request #2427 from luozhaoyu/master
Bug fix: field uri in digest authentication should not be empty when enc...
2015-04-06 10:19:15 -05:00
exvito 5a69137ac8 Issue #2334 - HTTPDigestAuth - Renamed thread local attribute
Per @sigmavirus24 suggestion: private and more readable.
2015-04-04 14:25:08 +01:00
exvito 36dea43406 Issue #2334 - HTTPDigestAuth - Improved per-thread state init
Inspired in @tardyp approach.
2015-04-03 17:04:33 +01:00
exvito e8d9bc55bc Issue #2334 - HTTPDigestAuth - All state now in thread local storage
Following feedback from tardyp and @vincentxb.
2015-04-03 14:21:29 +01:00
exvito e65360dbaf Issue #2334 - HTTPDigestAuth - Replace getattr utilization
Following Lukasa + kennethreitz suggestion.
2015-04-02 21:29:51 +01:00
exvito 845e8f943f Issue #2334 - HTTPAuthDigest - Making it thread-safe
The existing code counts the number of 401 responses in the num_401_calls
authenticator attribute. This is in place so as to ensure the necessary auth
header is sent, while avoiding infinite 401 loops (issue #547).

This commit makes num_401_calls an instance of threading.local() (previously
an integer), using num_401_calls.value as the counter.

It ensures that concurrent authentication requests get each their own counter
and behave as expected (otherwise every other concurrent request would have
its authentication fail).
2015-04-02 14:24:54 +01:00
Zhaoyu Luo fb1971778f Bug fix: field uri in digest authentication should not be empty when encounter http redirections 2015-01-25 18:11:22 -06:00
Ian Cordasco 677bbe30d7 Move noncebit to the only place it is used
Since we only allow for "auth" qop-value, hardcode it

Fixes #2408
2015-01-19 18:50:50 -06:00
Ian Cordasco 86c3ecfd34 Fix bug in renegotiating a nonce with the server
If a session runs long enough (without constant activity) then the server can
expire the nonce the session has negotiated. If that happens the session will
get a new 401 response which we were immediately returning to the user. A user
would then have to essentially reinitialize session.auth each time they get an
unexpected 401.

Also, there's no need for setattr calls when we can simply assign the
attribute on the instance.
2014-12-23 10:40:31 -06:00
Akira Kitada 67c505781c Fix HTTPDigestAuth not to treat non-file as a file
Ensure pos is set to None when the body is not a file
so that HTTPDigestAuth detects the type of the body correctly.
2014-11-13 00:51:35 +09:00
Yossi Gottlieb 3d8823cafc Clean up handle_redirect. 2014-10-23 13:46:44 +03:00
Yossi Gottlieb 6ff6f756c0 Clean up, support all redirects, fix potential endless 401 loop. 2014-10-08 00:06:01 +03:00
Yossi Gottlieb c28da22e9c A fix for #1979 repeat HTTP digest authentication after redirect. 2014-09-27 21:05:59 +03:00
Cory Benfield 2b8353d3b3 Avoid unnecessary encode/decode cycles. 2014-06-08 10:28:35 +01:00
Cory Benfield d977ee8a24 Force basic auth strings to native string type 2014-06-08 10:20:32 +01:00
Martijn Pieters 488b90f5ac Remove unused loggers. 2014-02-03 13:43:59 +00:00
Ian Cordasco e8bdcdb0a7 Address feedback from #1729
- Make the PreparedRequest's cookie jar an implementation detail
2013-12-04 06:45:18 -06:00
Chase Sterling 8bfe0d873f Store the request cookiejar in PreparedRequest.cookies fix #1728
Conflicts:
	requests/sessions.py
2013-12-04 06:38:58 -06:00
Cory Benfield fecb35a08e Quote qop values in digest auth. 2013-11-29 08:37:25 +00:00
Akira Kitada 3a9d9f2279 Fix hangs on streaming uploads with HTTPDigestAuth
When using Digest Authentication, the client resends the same request
after the server responds with the 401 "Unauthorized". However, when
doing streaming uploads, it gets stuck because the body data (a
file-like object) is already consumed at the initial request.

The patch fixes this by rewinding the file-like object before
resending the request.
2013-11-25 22:29:53 +09:00
daftshady 6931bd6715 second commit : Fixed #1623. Added 'MD5-sess' algorithm to HTTPDigestAuth 2013-10-26 18:14:19 +09:00
Ian Cordasco 22e31b4b73 Handle case when WWW-Authenticate returns multiple qops
In Digest Access Authentication there are two possible values (four if you
count the not-present and both cases) for authentication. We were narrowly
handling one of the four cases. Now we handle two.
2013-09-13 22:29:42 -05:00
Ian Cordasco 286ddb672d Take advantage of the new copy method 2013-07-27 23:08:46 -04:00
Ian Cordasco c25a72ea24 Make the regular tests pass
I broke Digest Auth completely
2013-07-27 23:07:25 -04:00
Ian Ross and Ian Cordasco 73635df1b2 Start work on sending cookies back
On 401's the cookies received aren't sent back to the server. See: #1336
2013-07-27 23:07:25 -04:00
Thomas Weißschuh 3b0d8b8e39 don't replace 'Digest' in digest header value
See https://github.com/kennethreitz/requests/issues/1358
2013-05-21 17:48:30 +00:00
Kenneth Reitz a527ecfabd Merge pull request #1242 from oviboy/master
HTTP Digest Auth case insensitive replacement of "Digest "
2013-04-13 20:28:43 -07:00
Pascal Borreli 037b38badb Fixed typos 2013-04-01 18:02:18 +00:00
Ovidiu Negrut 9d16c72767 compiled regex expression in digest auth, this also works in python 2.6.x 2013-03-25 12:28:25 +02:00