Skip to content

HTTPDigestAuth add optional Realm parameter to the authentication #6915

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

Closed
ideechaniz opened this issue Mar 18, 2025 · 1 comment
Closed
Labels
actions/autoclose-feat Used for automation to auto-close an issue Feature Request

Comments

@ideechaniz
Copy link

I noticed that urllib allows to specify the realm of a HTTPDigestAuth but the requests library doesn't allow it. Is it possible to add it on the standard requests library?

There are many devices that specify the realm where it is not the url domain name.
It is possible to do it with the urllib library that requests uses underneath.

Example (A Hickvision network camera):

#0000: GET /ISAPI/notification/alertStream HTTP/1.1
#002e: Host: 192.168.10.64
#43: Authorization: Digest username="admin",realm="iDS-TCM403-BI",non
#83: ce="4e45497a4d4459774e45553659544d334d6d55344d7a6b3d",uri="/ISAP
#00c3: I/notification/alertStream",cnonce="c9bc93c864ef47d8e6879678ad85
#103: 511c",nc=00000001,algorithm=MD5,response="ffeaecca50dc4b23a7bc68
#143: 6c0200c339",qop="auth"
#015b: User-Agent: curl/8.10.1
#174: Accept: /
#181: Connection: keep-alive

Where it would be a good idea to implement it:

from requests.auth import HTTPDigestAuth
At the auth.py file

It now only accepts two parameters:
https://requests.readthedocs.io/en/latest/user/authentication/

Use example with urllib without the requests library:

import urllib
import urllib.request

Examples:

Username="oneusername"
Password="onepassword"
Realm ="iDS-TCM403-BI"

password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(Realm, "http://192.168.10.64/", Username, Password)

handler = urllib.request.HTTPDigestAuthHandler(password_mgr)
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)

response = urllib.request.urlopen(URL)

=========================================

@ideechaniz ideechaniz added actions/autoclose-feat Used for automation to auto-close an issue Feature Request labels Mar 18, 2025
Copy link

As described in the template, Requests is not accepting feature requests

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2025
@github-actions github-actions bot locked as off-topic and limited conversation to collaborators Mar 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
actions/autoclose-feat Used for automation to auto-close an issue Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant