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

Fix url encoded credentials in netloc #82552

Merged
merged 1 commit into from
Jan 23, 2024
Merged

Fix url encoded credentials in netloc #82552

merged 1 commit into from
Jan 23, 2024

Commits on Jan 17, 2024

  1. Fix url encoded credentials in netloc

    Prior to this commit, it was impossible to use a module like dnf with a
    URL that contains a username with an @ such as an email address
    username, because:
    
      dnf:
        name: https://foo@example.com:bar@example.com/some.rpm
    
    Would cause netloc parsing to fail. However, the following:
    
      dnf:
        name: https://foo%40example.com:bar@example.com/some.rpm
    
    Would also fail because ansible would *not* URL-decode the credentials,
    causing the following to be base64 encoded in the Authorization header:
    
      Zm9vJTQwZXhhbXBsZS5jb206YmFyCg==
    
    Which decodes to:
    
      foo%40example.com:foo
    
    Which is *not* the authorized username, and as such, *won't* pass basic
    auth.
    
    With this commit, Ansible's url lib behaves like curl, chromium, wget,
    etc, and encodes the above to:
    
      Zm9vQGV4YW1wbGUuY29tOmJhcgo=
    
    Which decodes to:
    
      foo@example.com:bar
    
    Which will actually pass the HTTP Basic Auth, and is the same behaviour
    that you will find ie. with:
    
      curl -vvI https://foo%40bar:test@example.com 2>&1 |grep Auth | awk '{ print $4 }'
    jpic committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    1e5a12f View commit details
    Browse the repository at this point in the history