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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libfetchers/github.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ std::regex hostRegex(hostRegexS, std::regex::ECMAScript);

struct GitArchiveInputScheme : InputScheme
{
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));
Copy link
Member

@Mic92 Mic92 Dec 6, 2024

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
Member

Choose a reason for hiding this comment

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

Copy link
Member

@Mic92 Mic92 Dec 6, 2024

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
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.

Copy link
Member

@Mic92 Mic92 Dec 6, 2024

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
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
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.

}

std::optional<Input> inputFromURL(
const fetchers::Settings & settings,
Expand Down Expand Up @@ -486,6 +488,7 @@ struct GitLabInputScheme : GitArchiveInputScheme

struct SourceHutInputScheme : GitArchiveInputScheme
{

std::string_view schemeName() const override { return "sourcehut"; }

std::optional<std::pair<std::string, std::string>> accessHeaderFromToken(const std::string & token) const override
Expand Down
Loading