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

Auth: pak requires non-standard ports to be specified in .netrc, unlike curl #749

Open
glin opened this issue Mar 4, 2025 · 1 comment

Comments

@glin
Copy link

glin commented Mar 4, 2025

Testing .netrc support with pak 0.8.0.9000:

For repos with non-standard ports like http://127.0.0.1:11234, I'm finding that pak requires a port to be in .netrc:

machine 127.0.0.1:11234

Whereas curl only works if you omit the port:

machine 127.0.0.1

The .netrc documentation is sort of unclear here, but it sounds like it only supports hostnames in the machine field.


To repro, I am running this on Ubuntu 24.04:

  1. Start a server on http://127.0.0.1:11234
R
repo <- webfakes::new_app_process(pak:::auth_proxy_app(), port = 11234)
repo$url()
# [1] "http://127.0.0.1:11234/"
  1. Create a .netrc without port number, and curl works:
cat <<EOF > ~/.netrc
machine 127.0.0.1
login username
password token
EOF
chmod 600 ~/.netrc

curl --netrc -v http://127.0.0.1:11234
# *   Trying 127.0.0.1:11234...
# * Connected to 127.0.0.1 (127.0.0.1) port 11234
# * Server auth using Basic with user 'username'
# > GET / HTTP/1.1
# > Host: 127.0.0.1:11234
# > Authorization: Basic dXNlcm5hbWU6dG9rZW4=
# > User-Agent: curl/8.5.0
# > Accept: */*
# > 
# < HTTP/1.1 302 Found
  1. pak does not pick this up:
pak::repo_add(CRAN = repo$url(), username = "username")
pak::repo_get()
# x Did not find credentials for repo <http://[email protected]:11234/>, keyring lookup failed (env backend).
# # A data frame: 6 x 7
#   name          url           type  r_version bioc_version username has_password
# * <chr>         <chr>         <chr> <chr>     <chr>        <chr>    <lgl>       
# 1 CRAN          http://usern~ cran  *         NA           username FALSE    
  1. Create a .netrc with port number, and curl fails:
cat <<EOF > ~/.netrc
machine 127.0.0.1:11234
login username
password token
EOF
chmod 600 ~/.netrc

curl --netrc -v http://127.0.0.1:11234
# * Couldn't find host 127.0.0.1 in the .netrc file; using defaults
# *   Trying 127.0.0.1:11234...
# * Connected to 127.0.0.1 (127.0.0.1) port 11234
# > GET / HTTP/1.1
# > Host: 127.0.0.1:11234
# > User-Agent: curl/8.5.0
# > Accept: */*
# > 
# < HTTP/1.1 401 Unauthorized
  1. pak works here:
pak::repo_get()
v Found credentials for repo <http://[email protected]:11234/> (.netrc).
# A data frame: 6 x 7
  name          url           type  r_version bioc_version username has_password
* <chr>         <chr>         <chr> <chr>     <chr>        <chr>    <lgl>       
1 CRAN          http://usern~ cran  *         NA           username TRUE       
@glin glin changed the title pak requires non-standard ports to be specified in .netrc, unlike curl Auth: pak requires non-standard ports to be specified in .netrc, unlike curl Mar 4, 2025
@gaborcsardi
Copy link
Member

Thanks for the careful testing! Two things.

  1. We certainly should match hostnames without ports from the netrc file to hostnames with ports in the config file. This part is clear.
  2. Should we still support hostnames with ports in netrc files at all? Of course curl will not support that, but maybe we still can?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants