-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add Kerberos support for authentication with a flag (and appropriate dependencies being available) #11090
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
Add Kerberos support for authentication with a flag (and appropriate dependencies being available) #11090
Changes from all commits
08dc580
c936e14
87086bd
e6ce814
f9391d3
6db53d1
a8e46ef
5965c29
dc3936b
37fb3cf
84f62ad
e58196c
f717353
12e2840
b5bd385
e069cb5
fedf206
f53e289
33938dd
910b8a7
e2e1ba4
e8f8dbe
d966b5a
02cdfbf
a1049e4
3c24f5b
c8142af
8199d81
5acc560
1d96d55
647a4f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add kerberos support for authentication with the ``--enable-kerberos`` flag. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,6 +266,7 @@ def __init__( | |
cache: Optional[str] = None, | ||
trusted_hosts: Sequence[str] = (), | ||
index_urls: Optional[List[str]] = None, | ||
enable_kerberos: bool = False, | ||
**kwargs: Any, | ||
) -> None: | ||
""" | ||
|
@@ -281,8 +282,23 @@ def __init__( | |
# Attach our User Agent to the request | ||
self.headers["User-Agent"] = user_agent() | ||
|
||
no_prompt = MultiDomainBasicAuth(prompting=False, index_urls=index_urls) | ||
prompt = MultiDomainBasicAuth(prompting=True, index_urls=index_urls) | ||
prompt.passwords = no_prompt.passwords # share same dict of passwords | ||
|
||
# Attach our Authentication handler to the session | ||
self.auth = MultiDomainBasicAuth(index_urls=index_urls) | ||
if enable_kerberos: | ||
try: | ||
from requests_kerberos import REQUIRED, HTTPKerberosAuth | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a benchmark of this import? If it is relatively quick, we should probably just always enable Kerberos whenever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this to minimise this change having any impact on existing users that do not wish or want this support. E.g. one could imagine |
||
except ImportError: | ||
logger.critical( | ||
"Are you sure you `requests_kerberos` and its dependencies " | ||
"are available in the same environment as pip?" | ||
) | ||
raise | ||
self.auth = HTTPKerberosAuth(REQUIRED) | ||
else: | ||
self.auth = MultiDomainBasicAuth(index_urls=index_urls) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that we can’t use Basic Auth when Kerberos is enabled, or does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. My previous PR (see OP) did allow this but it requires a bunch more code to be added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not work in a Kerberos environment anymore, so I am not sure how likely it is people (or CICD) are to use/want this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ll OK with adding the feature, if someone’s willing to work on it (I don’t use Kerberos either). Let’s keep this open so someone can pick it up if they’re interested. |
||
|
||
# Create our urllib3.Retry instance which will allow us to customize | ||
# how we handle retries. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: need to fix this before merge.