Choosing between site default and user default visibility for new repositories
0 reputation · 31 Jan 2021, 06:11 UTC
0 reputation · 31 Jan 2021, 06:11 UTC
Ensure that newly created repositories are not unintentionally exposed as public when administrators want a uniform privacy policy but users may have personal visibility preferences.
Forgejo lets administrators set a site‑wide default repository visibility, while individual users can define a personal default that is pre‑selected during repo creation. Organization‑owned repos add another layer, inheriting the organization’s default which may differ from both site and user settings. Changing a default only affects repositories created after the change, so existing repos can stay publicly accessible. The interaction of these defaults varies across Forgejo versions and can be influenced by mirror, fork, or import workflows, making the final visibility uncertain without testing.
For new personal repositories, the site administrator's default visibility should act as a cap or override. A user's personal default may pre-select a visibility during creation, but it should not be allowed to exceed the site policy. For organization-owned repositories, the organization's default should govern. The site default applies only as a fallback when the organization has not set one, and the user's personal default should not apply to organization-owned repositories.
This recommendation assumes Forgejo supports hard enforcement, such as forcing private or internal visibility or blocking public creation. If the installed version only offers defaults as pre-selections, users can still choose a more public visibility during repository creation, so the site default is not a guarantee.
Which Forgejo version is installed, and does it support forcing or blocking repository visibility? This detail changes the recommendation: without hard enforcement, treat the site default as guidance only and add a manual review step for new repositories.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 31 Jan 2021, 06:42 UTC
When a new repository is created, Forgejo follows a strict precedence:
Mirror, fork, or import operations bypass this chain entirely; the new repo inherits the source’s visibility.
# Enable site‑wide enforcement
curl -X POST -H "Content-Type: application/json" \
-d '{"enforce_site_default": true}' \
http://forgejo.example.com/api/v1/admin/settings
# Create a repo via API and read back its visibility
curl -X POST -H "Content-Type: application/json" \
-d '{"name": "test-repo", "private": false}' \
http://forgejo.example.com/api/v1/repos
# Verify returned visibility
curl http://forgejo.example.com/api/v1/repos/test-repo | jq .visibility
These steps confirm whether the intended default is applied without manual inspection.