1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 19:01:16 +02:00

Fetch commits from github/gitlab using Auth header

`nix flake info` calls the github 'commits' API, which requires
authorization when the repository is private. Currently this request
fails with a 404.

This commit adds an authorization header when calling the 'commits' API.
It also changes the way that the 'tarball' API authenticates, moving the
user's token from a query parameter into the Authorization header.

The query parameter method is recently deprecated and will be disallowed
in November 2020. Using them today triggers a warning email.
This commit is contained in:
Greg Hale 2020-06-17 15:08:59 -04:00
parent 5080d4e7b2
commit a303c0b6dc
12 changed files with 84 additions and 31 deletions

View file

@ -201,8 +201,8 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
auto storePath =
unpack
? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).first.storePath
: fetchers::downloadFile(state.store, *url, name, (bool) expectedHash).storePath;
? fetchers::downloadTarball(state.store, *url, Headers {}, name, (bool) expectedHash).first.storePath
: fetchers::downloadFile(state.store, *url, Headers{}, name, (bool) expectedHash).storePath;
auto path = state.store->toRealPath(storePath);