ctaggart / SourceLink

Source Code On Demand
MIT License
356 stars 55 forks source link

sourcelink test in private github repo #371

Open maxild opened 5 years ago

maxild commented 5 years ago

Just enabled SourceLink for a nupkg build with code in private github repo. Running the SourceLink V3 dotnet global tool

sourcelink test .\artifacts\Brf.HisClientFx.0.2.0-aGH-6-0001.nupkg -u  personal_access_token

give me a lot of 404 errors

.
.
https://raw.githubusercontent.com/maxild/HisClientFx/72acf10621facd60df91ef2f4ca2c9720e71e2b7/src/Brf.HisClientFx/Polyfills/ReflectionPolyfillExtensions.cs
error: url failed NotFound: Not Found
.
.

I can download source files with curl without getting 404 errors

curl --header "Authorization: token personal_access_token" --location "https://raw.githubusercontent.com/maxild/HisClientFx/72acf10621facd60df91ef2f4ca2c9720e71e2b7/src/Brf.HisClientFx/Polyfills/ReflectionPolyfillExtensions.cs"

We both now that requests that require authentication will return 404 on Github. So why does the tool fail to authenticate. Am I doing something wrong?

ctaggart commented 5 years ago
 sourcelink test --help

Usage:  test [arguments] [options]

Arguments:
  path  path to pdb, dll or nupkg

Options:
  -f|--file <path>                the path to a dll or pdb in a nupkg
  -a|--use-auth <type>            Use authentication. Defaults to Basic
  -ae|--auth-encoding <encoding>  Encoding to use on authentication value. Defaults to ASCII
  -u|--username <username>        Username to use to authenticate
  -p|--password <password>        Password for the username that is use to authenticate
  -h|--help                       Show help information

I just looked at the code. Try adding a -a Basic.

maxild commented 5 years ago

But basic is the default value, so does that change anything?

maxild commented 5 years ago

@ctaggart Doesn't work with explicit Basic (=> 404), but the Authorization HTTP header is of the form

Authorization: <type> <credentials> 

but

sourcelink test .\artifacts\Brf.HisClientFx.0.2.0-aGH-6-0001.nupkg -a token -u personal_access_tokren

errors with Authentication type of token is not supported

maxild commented 5 years ago

I can also get

curl --header "Authorization: Basic base64('personal_access_token')" --location "https://raw.githubusercontent.com/maxild/HisClientFx/72acf10621facd60df91ef2f4ca2c9720e71e2b7/src/Brf.HisClientFx/Polyfills/ReflectionPolyfillExtensions.cs"

to work.

That is I base64 encode the ASCII(!) (not Unicode, unless UTF8...dotnet uses UTF16) representation of the token (or 'username:token' string...both work), but

sourcelink test .\artifacts\Brf.HisClientFx.0.2.0-aGH-6-0001.nupkg -a Basic -u base64(personal_access_token)

Invalid password value
Parameter name: password

Maybe the base64 encoding ring a bell. I have to leave, its late here.

maxild commented 5 years ago

@ctaggart BTW debugging in vs2017 works after adding , so the Visual Studio is able to authenticate with Github and download the (private) source...

Also the tool used to work with public Github repos for me, the only difference now I can't get it to authenticate with github

maxild commented 5 years ago

@ctaggart BTW debugging in vs2017 works after adding, so the debugger in Visual Studio is able to authenticate with Github and download the source...Also the tool used to work for me with public Github repos...

ctaggart commented 5 years ago

@maxild Sounds like it may be a bug in this app, so I'll reopen and take a look when I have time.

maxild commented 5 years ago

@ctaggart Oops didn't mean to close, glad you reopened it yourself:smile: