Skip to content

Allowing tokens on non-gitlab/github/srht git repos - #12006

Closed
P-E-Meunier wants to merge 1 commit into
NixOS:masterfrom
P-E-Meunier:master
Closed

P-E-Meunier wants to merge 1 commit into
NixOS:masterfrom
P-E-Meunier:master

Conversation

@P-E-Meunier

Copy link
Copy Markdown
Contributor

Motivation

The current implementation of the access-tokens directive in nix.conf doesn't obey its documentation nor the intuition behind it: indeed, while the docs mention "or other locations", in practice there are custom implementations for GitHub, GitLab and Sr.ht, while other providers aren't handled.

This causes flakes to fail authenticating when using the git+https: scheme instead of github:.

This fix only adds a default implementation.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@P-E-Meunier
P-E-Meunier requested a review from edolstra as a code owner December 4, 2024 12:06
@github-actions github-actions Bot added the fetching Networking with the outside (non-Nix) world, input locking label Dec 4, 2024
Comment thread src/libfetchers/github.cc
{
virtual std::optional<std::pair<std::string, std::string>> accessHeaderFromToken(const std::string & token) const = 0;
virtual std::optional<std::pair<std::string, std::string>> accessHeaderFromToken(const std::string & token) const {
return std::pair<std::string, std::string>("Authorization", fmt("Bearer %s", token));

@Mic92 Mic92 Dec 6, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know which type of git hosters/software support this scheme? This works with github and who else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mic92 Mic92 Dec 6, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. This seems common enough. Also because it seems to be related to oauth2.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also remove accessHeaderFromToken from SourceHut in this case.

@Mic92 Mic92 Dec 6, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what I am wondering is that you mentioned this would help with git+https. But I don't think this implementation is used for the git input scheme and all the other input types in this pull request are already handled. So which case did you fix here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I get a clearer picture: where is the handler for git+https?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchTree.cc is what you are looking for.

@Mic92

Mic92 commented Jan 7, 2025

Copy link
Copy Markdown
Member

Closing because of: #12006 (comment)

@Mic92 Mic92 closed this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants