Pass Gitea API token to requests#9
No reviewers
Labels
No labels
breaking
bug
build_pr_image
documentation
d̶u̶p̶l̶i̶c̶a̶t̶e̶
feature
good first issue
improvement
i̶n̶v̶a̶l̶i̶d̶
open questions
performance
refactor
research required
No milestone
No project
No assignees
3 participants Notifications
Due date No due date set.
Dependencies
No dependencies set.
Reference
Codeberg/pages-server!9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch ":main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In case you want to allow non-public repos, this should do the job. But I'm fine if we decide everything needs to be 100% public - this just adds the ability e.g. to use an API token from a random user who only has access to limited repos.
This allows to display repos that aren't fully public. Some users seem
to be very interested in not having their pages viewable, and it might
make even sense to avoid e.g. search engines to read them.
If set to some random user string, this could allow to set the
visibility at least to limited (so only logged users see the repo), and
should allow to view private repos in the future with another API token.
660022f2e5to772c17e214@ -39,6 +39,8 @@ var MainDomainSuffix = []byte("." + envOr("PAGES_DOMAIN", "codeberg.page"))// GiteaRoot specifies the root URL of the Gitea instance, without a trailing slash.var GiteaRoot = []byte(envOr("GITEA_ROOT", "https://codeberg.org"))var GiteaApiToken = []byte(envOr("GITEA_API_TOKEN", ""))why use []byte if it will get converted to string later?
Probably because the other variables used it? Reason for that is that
[]byteis preferred by fasthttp, but in this case it's only ever used in a string, so having it as a string here as well makes sense.Found a security issue (token gets exposed to the client), see code comments for details.
@ -153,3 +153,3 @@s.Step("raw domain preparations, now trying with specified branch")if tryBranch(targetRepo, pathElements[2][1:], pathElements[3:],string(GiteaRoot)+"/"+targetOwner+"/"+targetRepo+"/src/branch/%b/%p",string(GiteaRoot)+"/"+targetOwner+"/"+targetRepo+"/src/branch/%b/%p"+"?access_token="+string(GiteaApiToken),This is the "canonicalLink" argument that's exposed to the client as a
Linkheader (to indicate the official URL in Gitea to e.g. search engines), the token must not be added here!I'd prefer to only have it directly at
fasthttpRequests, so the token really only goes to Gitea.sorry, I missed this was the canonicalLink. I thought this would pass down to the default branch query, but missed this was another API call in getBranchTimestamp.
@ -165,3 +165,3 @@s.Step("raw domain preparations, now trying with default branch")tryBranch(targetRepo, "", pathElements[2:],string(GiteaRoot)+"/"+targetOwner+"/"+targetRepo+"/src/branch/%b/%p",string(GiteaRoot)+"/"+targetOwner+"/"+targetRepo+"/src/branch/%b/%p"+"?access_token="+string(GiteaApiToken),Same as #9/files (comment)
Wasn't able to properly test this, your ACME server is unavailable, but it feels alright.