Skip to content

Commit fc41c1e

Browse files
DavHauMic92
authored andcommitted
feat: add allowUnauthenticatedControl option
Allows unauthenticated users to perform control actions (cancel, restart, force builds) without authentication. Useful when running buildbot behind a VPN or on a local network where network-level access implies trust.
1 parent cd32d1c commit fc41c1e

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

buildbot_nix/buildbot_nix/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def _setup_www_config(
210210
admins=self.config.admins,
211211
backends=list(backends.values()),
212212
projects=succeeded_projects,
213+
allow_unauthenticated_control=self.config.allow_unauthenticated_control,
213214
)
214215

215216
def configure(self, config: dict[str, Any]) -> None:

buildbot_nix/buildbot_nix/authz.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,22 @@ async def match_BuildRequestEndpoint_stop( # noqa: N802
100100

101101

102102
def setup_authz(
103-
backends: list[GitBackend], projects: list[GitProject], admins: list[str]
103+
backends: list[GitBackend],
104+
projects: list[GitProject],
105+
admins: list[str],
106+
*,
107+
allow_unauthenticated_control: bool = False,
104108
) -> Authz:
105109
allow_rules = []
110+
111+
# When enabled, permit all control actions without authentication
112+
if allow_unauthenticated_control:
113+
allow_rules.append(util.AnyEndpointMatcher(role="", defaultDeny=False))
114+
return util.Authz(
115+
roleMatchers=[],
116+
allowRules=allow_rules,
117+
)
118+
106119
allowed_builders_by_org: defaultdict[str, set[str]] = defaultdict(
107120
lambda: {backend.reload_builder_name for backend in backends},
108121
)

buildbot_nix/buildbot_nix/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ class BuildbotNixConfig(BaseModel):
298298
effects_per_repo_secrets: dict[str, str] = {}
299299
show_trace_on_failure: bool = False
300300
cache_failed_builds: bool = False
301+
allow_unauthenticated_control: bool = False
301302

302303
def nix_worker_secrets(self) -> WorkerConfig:
303304
if self.nix_workers_secret_file is None:

examples/master.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
# branches = {
6868
# releaseBranches.matchGlob = "release-*";
6969
# };
70+
71+
# Allow unauthenticated users to perform control actions (cancel, restart, force builds).
72+
# Useful when running buildbot behind a VPN or on a local network.
73+
# allowUnauthenticatedControl = true;
7074
};
7175

7276
# Optional: Enable acme/TLS in nginx (recommended)

nixosModules/master.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ in
595595
regardless of previous failures
596596
'';
597597

598+
allowUnauthenticatedControl = lib.mkEnableOption ''
599+
allowing unauthenticated users to perform control actions (cancel, restart,
600+
force builds). Useful when running buildbot behind a VPN or on a local network
601+
where network-level access implies trust
602+
'';
603+
598604
outputsPath = lib.mkOption {
599605
type = lib.types.nullOr lib.types.path;
600606
description = "Path where we store the latest build store paths names for nix attributes as text files. This path will be exposed via nginx at \${domain}/nix-outputs";
@@ -847,6 +853,7 @@ in
847853
nix_workers_secret_file = "buildbot-nix-workers";
848854
show_trace_on_failure = cfg.showTrace;
849855
cache_failed_builds = cfg.cacheFailedBuilds;
856+
allow_unauthenticated_control = cfg.allowUnauthenticatedControl;
850857
}
851858
}").read_text()))
852859
)

0 commit comments

Comments
 (0)