1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-19 23:09:37 +02:00

feat: test and document access-token prefix support

This commit is contained in:
Thomas Bereknyei 2025-02-13 06:05:54 -05:00
parent 69c7b42d28
commit a9f4d73d3e
5 changed files with 89 additions and 4 deletions

View file

@ -23,9 +23,11 @@ struct Settings : public Config
Access tokens are specified as a string made up of
space-separated `host=token` values. The specific token
used is selected by matching the `host` portion against the
"host" specification of the input. The actual use of the
`token` value is determined by the type of resource being
accessed:
"host" specification of the input. The `host` portion may
contain a path element which will match against the prefix
URL for the input. (eg: `github.com/org=token`). The actual use
of the `token` value is determined by the type of resource
being accessed:
* Github: the token value is the OAUTH-TOKEN string obtained
as the Personal Access Token from the Github server (see

View file

@ -264,6 +264,9 @@ struct InputScheme
virtual std::optional<std::string> isRelative(const Input & input) const
{ return std::nullopt; }
virtual std::optional<std::string> getAccessToken(const fetchers::Settings & settings, const std::string & host, const std::string & url) const
{ return {};}
};
void registerInputScheme(std::shared_ptr<InputScheme> && fetcher);

View file

@ -172,7 +172,7 @@ struct GitArchiveInputScheme : InputScheme
return input;
}
std::optional<std::string> getAccessToken(const fetchers::Settings & settings, const std::string & host, const std::string & url) const
std::optional<std::string> getAccessToken(const fetchers::Settings & settings, const std::string & host, const std::string & url) const override
{
auto tokens = settings.accessTokens.get();
std::string answer;