Watch
0
0
Fork
You've already forked hyperhive
0

lock the service forge accounts out of creating organizations

This commit is contained in:
atlas 2026-11-16 21:40:02 +01:00
commit 87dc4c5533

View file

@ -2183,16 +2183,17 @@ fn legacy_agent_email(agent: &str) -> String {
format!("{agent}@hive.local")
}
/// The `admin_edit_user` body that sets `max_repo_creation = 0` on `agent`
/// and nothing else. `login_name` + `source_id = 0` (local auth,
/// which is what [`Client::create_agent_user`] creates) ride along because
/// Forgejo resets `use_custom_avatar` on an admin edit that omits
/// `login_name`; every other field is left unset so nothing else is touched.
/// The `admin_edit_user` body that sets `max_repo_creation = 0` and
/// `allow_create_organization = false` on `agent` and nothing else.
/// `login_name` + `source_id = 0` (local auth, which is what
/// [`Client::create_agent_user`] creates) ride along because Forgejo resets
/// `use_custom_avatar` on an admin edit that omits `login_name`; every other
/// field is left unset so nothing else is touched.
fn repo_creation_lockdown(agent: &str) -> EditUserOption {
EditUserOption {
active: None,
admin: None,
allow_create_organization: None,
allow_create_organization: Some(false),
allow_git_hook: None,
allow_import_local: None,
description: None,
@ -2214,11 +2215,9 @@ fn repo_creation_lockdown(agent: &str) -> EditUserOption {
}
/// [`repo_creation_lockdown`] for an agent's account: `max_repos` repositories
/// instead of none, and no organizations. The service accounts that share the
/// lockdown stay at none and are not touched on organizations.
/// instead of none.
fn agent_account_lockdown(agent: &str, max_repos: u32) -> EditUserOption {
EditUserOption {
allow_create_organization: Some(false),
max_repo_creation: Some(i64::from(max_repos)),
..repo_creation_lockdown(agent)
}