Repository visibility defaults may expose private projects unintentionally in Forgejo
0 reputation · 22 Apr 2020, 00:10 UTC
0 reputation · 22 Apr 2020, 00:10 UTC
Forgejo's repository visibility controls support private, limited, and public settings, with organization-level and global defaults configurable through the admin dashboard. However, the current implementation does not appear to enforce explicit visibility selection during repository creation, which may cause new repositories to inherit unintended visibility settings from templates or organizational defaults.
The concern centers on whether Forgejo provides a mechanism to require administrators to explicitly choose visibility during repository creation, or if templates and default settings can inadvertently expose repositories that should remain private. This is particularly relevant for self-hosted instances where privacy controls are a primary design goal.
Key areas to verify: the Admin > Settings > Repository visibility options, organization-level default repository settings, the repository creation flow for required visibility selection, and template repository inheritance behavior. The documentation does not clearly specify whether explicit visibility selection can be mandated.
1. Does Forgejo support configuring a requirement for explicit visibility selection during repository creation?
2. How do template repositories inherit or override visibility settings from their source?
3. What is the recommended approach to prevent accidental public exposure of private projects?
35275 reputation · 22 Apr 2020, 05:06 UTC
1. Can Forgejo require explicit visibility selection during repository creation? No. Forgejo (inheriting Gitea's configuration model) has no setting that forces the creation form to require a deliberate click on a visibility option. The form always pre-selects a value derived from your defaults, so a user can click straight through and accidentally create a public repository.
2. How do template repositories handle visibility? Visibility is not blindly inherited from the source template. When you create a repository from a template, the creation form offers a visibility choice that defaults per your instance configuration — the template's content is copied, but the new repository's visibility is whatever the form says when you submit.
3. What prevents accidental public exposure? Since you can't mandate a choice, you change the default: set the default visibility to private in app.ini, and optionally restrict who may publish publicly at all. Details below.
In app.ini, under the [repository] section:
[repository]
DEFAULT_PRIVATE = private
DEFAULT_PUSH_CREATE_PRIVATE = private
DEFAULT_PRIVATE accepts last (remember the user's previous choice), private, or public. Setting it to private means the creation form pre-selects private, so publishing publicly requires a deliberate change. DEFAULT_PUSH_CREATE_PRIVATE covers repositories created implicitly by pushing to a non-existent repo — an easy exposure path to overlook. Restart Forgejo after editing.
Forgejo/Gitea support a limited visibility state: repositories and users hidden from anonymous visitors but visible to logged-in users. If your instance is team-internal, setting user or organization visibility to limited or private constrains what members can publish publicly — though note this affects user profiles too, not just repositories. Check your version's admin dashboard under the organization and user settings for the visibility field.
Option names and admin UI paths vary between Forgejo versions, so confirm against your deployed version's config cheat sheet. Concretely:
grep -A5 '\[repository\]' /path/to/app.ini and check both keys above.DEFAULT_PRIVATE only affects new repositories. Use the admin dashboard's repository list filtered by public visibility to catch projects already exposed.This reflects Forgejo's inherited Gitea behavior as generally documented; exact key names should be confirmed against your version. The core limitation stands: Forgejo offers safe defaults and visibility restrictions, but no mandatory explicit-selection step in the creation flow. If that hard requirement matters to you, the realistic options are the private default plus user/org visibility limits, or a policy enforced outside Forgejo (e.g., periodic audits via the API).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.