Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildbot_nix/buildbot_nix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def _setup_www_config(
admins=self.config.admins,
backends=list(backends.values()),
projects=succeeded_projects,
allow_unauthenticated_control=self.config.allow_unauthenticated_control,
)

def configure(self, config: dict[str, Any]) -> None:
Expand Down
15 changes: 14 additions & 1 deletion buildbot_nix/buildbot_nix/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,22 @@ async def match_BuildRequestEndpoint_stop( # noqa: N802


def setup_authz(
backends: list[GitBackend], projects: list[GitProject], admins: list[str]
backends: list[GitBackend],
projects: list[GitProject],
admins: list[str],
*,
allow_unauthenticated_control: bool = False,
) -> Authz:
allow_rules = []

# When enabled, permit all control actions without authentication
if allow_unauthenticated_control:
allow_rules.append(util.AnyEndpointMatcher(role="", defaultDeny=False))
return util.Authz(
roleMatchers=[],
allowRules=allow_rules,
)

allowed_builders_by_org: defaultdict[str, set[str]] = defaultdict(
lambda: {backend.reload_builder_name for backend in backends},
)
Expand Down
1 change: 1 addition & 0 deletions buildbot_nix/buildbot_nix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class BuildbotNixConfig(BaseModel):
effects_per_repo_secrets: dict[str, str] = {}
show_trace_on_failure: bool = False
cache_failed_builds: bool = False
allow_unauthenticated_control: bool = False

def nix_worker_secrets(self) -> WorkerConfig:
if self.nix_workers_secret_file is None:
Expand Down
4 changes: 4 additions & 0 deletions examples/master.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
# branches = {
# releaseBranches.matchGlob = "release-*";
# };

# Allow unauthenticated users to perform control actions (cancel, restart, force builds).
# Useful when running buildbot behind a VPN or on a local network.
# allowUnauthenticatedControl = true;
};

# Optional: Enable acme/TLS in nginx (recommended)
Expand Down
7 changes: 7 additions & 0 deletions nixosModules/master.nix
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ in
regardless of previous failures
'';

allowUnauthenticatedControl = lib.mkEnableOption ''
allowing unauthenticated users to perform control actions (cancel, restart,
force builds). Useful when running buildbot behind a VPN or on a local network
where network-level access implies trust
'';

outputsPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
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";
Expand Down Expand Up @@ -847,6 +853,7 @@ in
nix_workers_secret_file = "buildbot-nix-workers";
show_trace_on_failure = cfg.showTrace;
cache_failed_builds = cfg.cacheFailedBuilds;
allow_unauthenticated_control = cfg.allowUnauthenticatedControl;
}
}").read_text()))
)
Expand Down
Loading