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

Add Kerberos support for authentication with a flag (and appropriate dependencies being available) #11090

Closed
wants to merge 31 commits into from

Conversation

cryvate
Copy link

@cryvate cryvate commented May 6, 2022

This closes #6708 and is tangential to #4475.

This makes Kerberos authentication available with a flag (--enable-kerberos).

This is based on another PR, with the following high level difference:

  • Merge conflicts resolved
  • No vendoring
  • No change if flag disabled
  • When Kerberos is enabled, it is required to have a valid Kerberos ticket (this meant no fall backs like in the original PR required).

This means the size of the PR tiny.

I have tested with a Ubuntu 20.04 Kerberos installation that the authentication works. I am happy to have others test it, but won't post the details here publicly.

@cryvate cryvate marked this pull request as ready for review May 6, 2022 03:00
@pradyunsg pradyunsg closed this May 6, 2022
@pradyunsg pradyunsg reopened this May 6, 2022
Kerberos Authentication
-----------------------

Starting with vXX.X, pip supports using a Kerberos ticket to authenticate
Copy link
Member

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.

self.auth = MultiDomainBasicAuth(index_urls=index_urls)
if enable_kerberos:
try:
from requests_kerberos import REQUIRED, HTTPKerberosAuth
Copy link
Member

Choose a reason for hiding this comment

The 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 requests_kerberos is present in the environment, similar to how we handle keyring support.

Copy link
Author

Choose a reason for hiding this comment

The 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 requests_kerberos ends up raising something that is not ImportError (for whatever reason) and then this code would fail. I think going more defensive is not the way (we would want this to bubble up), but we do not want this impacting users that don't want to use kerberos (with pip).

raise
self.auth = HTTPKerberosAuth(REQUIRED)
else:
self.auth = MultiDomainBasicAuth(index_urls=index_urls)
Copy link
Member

Choose a reason for hiding this comment

The 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 requests_kerberos handle Basic Auth for us?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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.

src/pip/_internal/utils/logging.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added the needs rebase or merge PR has conflicts with current master label May 30, 2022
Copy link
Author

@cryvate cryvate left a comment

Choose a reason for hiding this comment

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

github interface being janky, so adding some suggestions so I can do some changes online

src/pip/_internal/utils/logging.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/logging.py Outdated Show resolved Hide resolved
@pradyunsg
Copy link
Member

pradyunsg commented Sep 30, 2022

Going to go ahead and close this, since it has merge conflicts that haven't been resolved in a while. Please feel welcome to file a new PR or to reopen and update this one (assuming that's what the existing discussions point toward)!

@pradyunsg pradyunsg closed this Sep 30, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kerberos support
3 participants