CORS for packages #2144
Labels
No labels
accessibility
bug
bug
infrastructure
Codeberg
contributions welcome
docs
duplicate
enhancement
infrastructure
legal
licence / ToS
please chill
we are volunteers
public relations
question
question
user support
s/Forgejo
s/Forgejo/migration
s/Pages
s/Weblate
s/Woodpecker
security
service
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Codeberg/Community#2144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Comment
When packages are hosted in public Codeberg organizations, they are generally accessible, but not from web browsers (which'd require CORS).
Practical use cases for this are all situations when JupyterLite notebooks install packages from a repository: In those cases, Python (or Ruby or R) are running inside a browser's WASM engine. For example, aiocoap uses this in its documentation to enable users to explore the library without any installation. As a workaround, I'm manually mirroring its packages to an own server with fuller CORS control.
Please consider activating CORS at least for the generated indices and the packages themselves. As I understand discussion on Forgejo enabling this, it already has the right knobs (although I'm not sure if their granularity suffices).
Security implications
As I understand, the basic CORS setting (
Access-Control-Allow-Origin: *
) will only allow browsers to send requests that don't send access control headers, so no special considerations are needed for private package repos (if that's even a thing on Codeberg). This would be a problem if Codeberg operated under the assumption that certain IP addresses are privileged to see some information, but Codeberg being a public service, I don't think that's the case.Crawling implications
Only hypothetical implications: If Codeberg does block certain IP ranges from accessing packages (as AIU it is done during the current bursts bot activity), the crawlers could commandeer people's browsers and make them download on their behalf, turning crawling into a distributed thing. However, that'd require the bot operators to lure users onto their own pages – and those own pages then still do show up in "Origin:" headers sent by the browser, so they could be blocked that way.
@chrysn wrote in #2144 (comment):
No, there is no feature in Forgejo that would enable CORS for the package routes. CORS is otherwise already enabled:
[cors]
ENABLED = true
ALLOW_DOMAIN = *
The comment refers to adding it to Codeberg's reverse proxy setup to add this CORS, which is not something we would like to do. It should be implemented in Forgejo, adding CORS support for some route in a reverse proxy is not that trivial.
@chrysn wrote in #2144 (comment):
We already have CORS enabled for the general API, so that shouldn't be too much of a new implication.
Thanks. I'll see with that what I can do in the Forgejo issue; I'd welcome you to join me there to avoid the Telephone Game if you can spare the mindshare for it (but hope to get it moving from the feedback you already provided).