Gitea sources without a token: direct archive links

With REQUIRE_SIGNIN_VIEW off, public Gitea repositories can be read
anonymously, so the token is no longer required. Without one, the server
calls the Gitea API without credentials and hands workers the plain
<repo>/archive/<commit>.zip link, like Github. With a token, private
repositories still go through the signed /giteaSource/ proxy.

When a lookup fails without a token, the error says the repository must
be public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rektdieandclaude committed 2026-11-15 01:30:15 +01:00
1 parent 30032fd42d
commit 4bd7a68864
2 files changed
+22 -11

No files matched your search

+16 -5
View File
@@ -21,13 +21,19 @@
# Everything OpenBench needs to know about where engine sources live. # Everything OpenBench needs to know about where engine sources live.
# #
# Sources can be on Github, or on a Gitea server listed under "gitea_hosts" in # Sources can be on Github, or on a Gitea server listed under "gitea_hosts" in
# Config/config.json. A Gitea server is reached with the API token stored in # Config/config.json.
# Config/credentials.gitea, and that token is never sent to any other host.
# #
# Workers download sources with a plain GET and no credentials. Github archives # Workers download sources with a plain GET and no credentials. Github archives
# are public, so workers fetch them directly. Gitea servers may require a login # are public, so workers fetch them directly. For Gitea there are two modes:
# even to read, so the server hands workers a signed link to /giteaSource/, #
# which fetches the archive with the token and passes it through. # - Without a token, the repository must be readable anonymously (public, and
# REQUIRE_SIGNIN_VIEW off on the Gitea server). The API is called without
# credentials and workers get the plain archive link, exactly like Github.
#
# - With an API token in Config/credentials.gitea, private repositories and
# servers that require a login work too. The token is never sent to any other
# host. Workers cannot log in, so the server hands them a signed link to
# /giteaSource/, which fetches the archive with the token and passes it on.
# #
# The links are signed with the Gitea token itself, not Django's SECRET_KEY: # The links are signed with the Gitea token itself, not Django's SECRET_KEY:
# settings.py is part of the public repository, and a forged link would let # settings.py is part of the public repository, and a forged link would let
@@ -178,6 +184,11 @@ def source_url(request, repo, commit):
if not is_gitea(repo): if not is_gitea(repo):
return '%s/archive/%s.zip' % (repo.rstrip('/'), commit['tree']) return '%s/archive/%s.zip' % (repo.rstrip('/'), commit['tree'])
# Without a token the repository is public: workers download it directly.
# Gitea archives are addressed by commit, not by tree.
if not read_gitea_token():
return '%s/archive/%s.zip' % (repo.rstrip('/'), commit['sha'])
query = urllib.parse.urlencode({ query = urllib.parse.urlencode({
'repo' : repo.rstrip('/'), 'repo' : repo.rstrip('/'),
'sha' : commit['sha'], 'sha' : commit['sha'],
+6 -6
View File
@@ -390,11 +390,10 @@ def collect_github_info(errors, request, field):
errors.append('OpenBench may only reach Github\'s API or a configured Gitea server') errors.append('OpenBench may only reach Github\'s API or a configured Gitea server')
return (None, None) return (None, None)
# Gitea servers get their own token, and nothing else. The token also signs # Gitea servers get their own token if there is one, and nothing else.
# the source links handed to workers, so there is no Gitea without one. # Without a token the repository has to be readable anonymously.
if gitea and not (headers := OpenBench.git_hosts.gitea_headers()): if gitea:
errors.append('Server does not have a Gitea token (Config/credentials.gitea)') headers = OpenBench.git_hosts.gitea_headers()
return (None, None)
## Step 2: Connect to the Github or Gitea API for the given Branch or Commit SHA. ## Step 2: Connect to the Github or Gitea API for the given Branch or Commit SHA.
## [A] We will attempt to parse the most recent commit message for a ## [A] We will attempt to parse the most recent commit message for a
@@ -412,7 +411,8 @@ def collect_github_info(errors, request, field):
except: # Unable to find for whatever reason except: # Unable to find for whatever reason
traceback.print_exc() traceback.print_exc()
errors.append('%s could not be found' % (branch or 'Branch')) hint = ' (no Gitea token on the server, so the repository must be public)' if gitea and not headers else ''
errors.append('%s could not be found%s' % (branch or 'Branch', hint))
return (None, None) return (None, None)
# Extract the bench from the web form, or from the commit message # Extract the bench from the web form, or from the commit message