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

HTTP Digest authentication support #131

Merged
merged 66 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
31197b8
Added HTTP Digest authentication support
mksh Mar 3, 2015
fffaaca
Added docstrings; got rid of assertDictEqual in test_digest_auth_mult…
mksh Mar 3, 2015
0c5d729
PEP8
mksh Mar 3, 2015
1d3b18c
Docstrings, typing fixes and small code improvements
mksh Mar 13, 2015
42d695d
Fix POST Request Digest Authentication
jameshilliard Jul 31, 2016
e749665
python 3 urlparse compatibility
jameshilliard Aug 1, 2016
a627f0b
Refactor build_digest_authentication_header as a private method of _R…
jameshilliard Sep 10, 2016
aa8e102
Make username and password private
jameshilliard Sep 10, 2016
2c1817e
Remove redundant agent arguement from _build_digest_authentication_he…
jameshilliard Sep 11, 2016
91a5c7b
Remove redundant None default from self.digest_auth_cache.get
jameshilliard Sep 11, 2016
19f6ad8
Use bytes instead of strings
jameshilliard Sep 11, 2016
1848e93
Fix python 3 digest hash encoding
jameshilliard Sep 12, 2016
5651fc3
Use byte encoding for MD5-SESS digest
jameshilliard Sep 12, 2016
2e2e6d8
Merge branch 'master' of https://github.com/twisted/treq into HTTPDig…
jameshilliard May 11, 2017
9e6e298
Fix python3 auth multiple calls test
jameshilliard May 11, 2017
ffdbfa7
Pass correct algorithm back for digest auth
jameshilliard May 11, 2017
4bd52ff
set default algorithm for digest auth
jameshilliard May 11, 2017
a4dd9f2
PEP8
jameshilliard May 11, 2017
05ecf65
sha256 digest support
jameshilliard May 11, 2017
4ae05dc
Merge branch 'master' into HTTPDigestAuth
jameshilliard Oct 29, 2017
b9f4452
Merge branch 'master' into HTTPDigestAuth
jameshilliard Nov 7, 2017
1283fea
Merge branch 'master' of https://github.com/twisted/treq into HTTPDig…
jameshilliard Sep 29, 2018
03b784b
bump httpbin version
jameshilliard Sep 29, 2018
3515008
Add more tests and sha512 digest support.
jameshilliard Sep 29, 2018
e0d7208
Set opaque header for digest auth
jameshilliard Sep 29, 2018
457c56a
Merge branch 'upstream-master' into HEAD
mksh Feb 7, 2020
f8c5e7f
Make treq.auth.generate_client_nonce() private
mksh Feb 7, 2020
dcc772d
Refactor digest auth parameter caching, add unit tests
mksh Feb 7, 2020
f1e3222
None is default ret value of .get()
mksh Feb 7, 2020
00af1b7
Fix flakes for test_auth.py
mksh Feb 7, 2020
8ca2274
Merge branch 'master' into feature/http-digest-auth
Mar 30, 2020
7dba100
Merge branch 'master' into feature/http-digest-auth
glyph Dec 1, 2020
8150f5d
Merge branch 'trunk' into HTTPDigestAuth
jameshilliard Nov 9, 2022
ec3e5c9
Use urlparse from urllib instead of six
jameshilliard Nov 23, 2022
259a059
Add type annotations
jameshilliard Nov 23, 2022
c5a6e86
Fix digest auth comment links
jameshilliard Nov 23, 2022
f5a30ea
Improve digest auth howto caching wording
jameshilliard Nov 23, 2022
b87b767
Add blank lines around param comments
jameshilliard Nov 23, 2022
d01bd08
Don't hardcode qop as auth
jameshilliard Nov 23, 2022
73a68d3
Use agent_spy instead of mock in test_add_digest_auth.
jameshilliard Nov 23, 2022
b1ade85
Use self.patch instead of MonkeyPatcher
jameshilliard Nov 23, 2022
d9a48a6
Use nonlocal for call counter variable
jameshilliard Nov 23, 2022
455605d
Cleanup test_digest_auth_multiple_calls nonlocal variable naming and …
jameshilliard Nov 23, 2022
12c0739
Make cached_metadata_for private
jameshilliard Nov 26, 2022
4a8e463
Fix treq integration test docstring indentation
jameshilliard Nov 26, 2022
99a0532
Refactor build_authentication_header based on current requests fstrin…
jameshilliard Nov 26, 2022
5269ff1
Make build_authentication_header private
jameshilliard Nov 27, 2022
4cbd556
Use _DIGEST_ALGO enum for digest auth algo
jameshilliard Nov 27, 2022
5359a2a
Improve and add additional digest auth test docstring
jameshilliard Nov 27, 2022
484b9ba
Merge commit '08bb4d3f878e79c6d0755fd80b74ffd9ccdc2726' into HTTPDige…
jameshilliard May 2, 2023
bcb946d
Merge branch 'trunk' into HTTPDigestAuth
glyph May 3, 2023
57769c9
Merge branch 'trunk' into HTTPDigestAuth
twm Apr 20, 2024
b5f5d95
Merge branch 'trunk' into HTTPDigestAuth
glyph Jun 18, 2024
f833561
version bump on mypy basepython
glyph Jun 18, 2024
1c35956
current brotlipy doesn't build against 3.10 any more, mypy transitive…
glyph Jun 18, 2024
9198250
try to catch up this PR with the new, stricter requirements treq has …
glyph Jun 18, 2024
e1cf128
add test-case-name
glyph Jun 18, 2024
580eb8a
now that we're using enums properly, format them properly
glyph Jun 18, 2024
92fd51c
upgrade setup-python to correspond to new mypy basepython
glyph Jun 18, 2024
ae9d582
same mistake again on the docs env
glyph Jun 18, 2024
ffa168e
annotations import
glyph Jun 18, 2024
7ab4927
extend test-case-name for the missed parts
glyph Jun 18, 2024
fc145a4
no peeking at private attributes
glyph Jun 18, 2024
c27e977
Update src/treq/auth.py
glyph Jun 19, 2024
badf9fb
remove unnecessary extra public API
glyph Jun 19, 2024
a688242
Merge branch 'trunk' into HTTPDigestAuth
glyph Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/examples/digest_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from twisted.internet.task import react
from _utils import print_response

import treq
from treq.auth import HTTPDigestAuth


def main(reactor, *args):
d = treq.get(
'http://httpbin.org/digest-auth/auth/treq/treq',
auth=HTTPDigestAuth('treq', 'treq')
)
d.addCallback(print_response)
return d

react(main, [])
20 changes: 20 additions & 0 deletions docs/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ The ``auth`` argument should be a tuple of the form ``('username', 'password')``

Full example: :download:`basic_auth.py <examples/basic_auth.py>`

HTTP Digest authentication is supported by passing an instance of
:py:class:`treq.auth.HTTPDigestAuth` to any of the request functions by using the `auth` keyword argument.
We support only "auth" QoP as defined at `RFC 2617`_
or simple `RFC 2069`_ without QoP at the moment. Treq takes care of
HTTP digest credentials caching - after authorization on any URL/method pair,
the library will use the first time received HTTP digest credentials on that endpoint
for further requests, and will not perform any redundant requests for obtaining the creds.
jameshilliard marked this conversation as resolved.
Show resolved Hide resolved

:py:class:`treq.auth.HTTPDigestAuth` class accepts ``username`` and ``password``
as constructor arguments.

.. literalinclude:: examples/digest_auth.py
:linenos:
:lines: 5-14

Full example: :download:`digest_auth.py <examples/digest_auth.py>`

.. _RFC 2617: http://www.ietf.org/rfc/rfc2617.txt
.. _RFC 2069: http://www.ietf.org/rfc/rfc2069.txt

Redirects
---------

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Here is a list of `requests`_ features and their status in treq.
+----------------------------------+----------+----------+
| Basic Authentication | yes | yes |
+----------------------------------+----------+----------+
| Digest Authentication | yes | no |
| Digest Authentication | yes | yes |
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

+----------------------------------+----------+----------+
| Elegant Key/Value Cookies | yes | yes |
+----------------------------------+----------+----------+
Expand Down
Loading