Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/pipPublic
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

WIP: Fix - Cannot access private repository using token#6795

Closed
booleand wants to merge4 commits intopypa:masterfrombooleand:fix-auth-single-cred

Conversation

booleand
Copy link

This PR addresses a potential bug from 19.2 as discussedhere.

Embedding a token in anindex_url is not working.

For example:

pip install SomeProject --index-url="https://TOKEN@some.where/somerepo/"

throws an exception:pip._internal.exceptions.DistributionNotFound

Any guidance/feedback would be appreciated!

@chrahunt
Copy link
Member

Resolves#6796.

@pradyunsg
Copy link
Member

/cc@zooba since this was modified last in the keyring PR, which is what git bisect points to as well.

booleand reacted with thumbs up emoji

@booleand
Copy link
Author

Potential test case

def test_get_single_credential():    auth = MultiDomainBasicAuth()    get = auth._get_url_and_credentials    assert get("http://token@example.com/path") \        == ('http://example.com/path', 'token', None)    assert auth.passwords['example.com'] == ('token', None)

To place in:

deftest_get_credentials():

@zooba
Copy link
Contributor

ConvertingNone to"" sounds reasonable to me. Though there may also be issues with the caching if we parse"" out of a URL but are expecting/looking forNone.

I've paged all of this code out of my head already, I'm afraid, so without going through and relearning it I can't really offer much help, sorry :)

pradyunsg reacted with thumbs up emoji

@pradyunsg
Copy link
Member

Hehe. No worries@zooba! Thanks for chiming in.

I'm hoping I'll be able to make time to look into this today or tomorrow.

@pradyunsg
Copy link
Member

@booleand Would you mind if I pick this up from here?

@booleand
Copy link
Author

booleand commentedJul 30, 2019
edited
Loading

@booleand Would you mind if I pick this up from here?

@pradyunsg OK

Just want to mention a few things:

  1. Need to consider which conditional to use on this line as the behavior will be different:

ifusernameisNoneandpasswordisNone:

I suspect there may be edge cases which will result in unexpected behavior. In particular when multiple calls are being made to aMultiDomainBasicAuth object.

  1. Here is a summary of changes inMultiDomainBasicAuth:
  • _get_new_credentials now returns ausername even if itdoesn't locate a password.

  • _get_url_and_credentials calls_get_new_credentialsonly when bothusername andpassword are empty. Though this may need to be reconsidered depending on requirements.

  • _get_url_and_credentials storesusername and/orpassword wheneither is found.

  • __call__ now instantiates and calls aHTTPBasicAuth wheneitherusername orpassword is present. It also converts anyNoneTypes to an empty string.

  1. Here is a potential test case forMultiDomainBasicAuth.__call__ :
def test_basic_auth_with_url_embedded_token():    with patch.object(pip._internal.download.HTTPBasicAuth, '__call__') as mock_auth:        auth = MultiDomainBasicAuth()        req = MockRequest("http://token@example.com/path")        auth(req)    assert mock_auth.called_with('token', '')

@pradyunsg
Copy link
Member

Thanks@booleand!

consider which conditional to use on this line

I decided to preserve that conditional as is, and modified what_get_url_and_credentials would return. The guard, as it stands, seems to be correct to me.

summary of changes

Thank you -- these helped. :)

potential test case

I ended up augmenting existing tests:0832006.

@locklockbot added the auto-lockedOutdated issues that have been locked by automation labelSep 3, 2019
@locklockbot locked asresolvedand limited conversation to collaboratorsSep 3, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@cjerdonekcjerdonekcjerdonek left review comments

Assignees
No one assigned
Labels
auto-lockedOutdated issues that have been locked by automation
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@booleand@chrahunt@pradyunsg@zooba@cjerdonek@moseshassan

[8]ページ先頭

©2009-2025 Movatter.jp