diff --git a/nix/checks.nix b/nix/checks.nix index fd89b2adb..88c2907d2 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -23,15 +23,6 @@ in { formatting = treefmt-eval.config.build.check self; - # The module-eval suite below only evaluates, so nothing else builds - # nginx's config file, whose derivation runs gixy over it. Naming the - # `ExecStart` that points at it makes this derivation depend on it, so a - # directive gixy refuses fails here instead of in a host build. The - # single-host swarm fixture serves the swarm UI vhost. - nginx-conf-all-local = pkgs.runCommand "nginx-conf-all-local" { } '' - echo ${pkgs.lib.escapeShellArg moduleEvalShared.allLocal.systemd.services.nginx.serviceConfig.ExecStart} > $out - ''; - # The only checks here that cover **nix**. Every other one is a Rust # derivation, so a `.nix`-only diff moves no hash and the whole set is # cache hits — green without evaluating what changed. See diff --git a/nix/host-modules/swarm-ui.nix b/nix/host-modules/swarm-ui.nix index a8ccfd43f..ee3cf1bf6 100644 --- a/nix/host-modules/swarm-ui.nix +++ b/nix/host-modules/swarm-ui.nix @@ -323,12 +323,8 @@ in # 401 with a `WWW-Authenticate` header, which the UI reads as "log in # again" and answers with a reload. The header is also how the UI tells # this 401 from one the controller sends for its own reasons. - # The security headers are repeated inside the `if` block that sets its - # own `add_header`, which would otherwise drop them. "@swarm_api_unauthorized".extraConfig = '' - ${gatewayCfg.lib.securityHeaders} if ($http_authorization) { - ${gatewayCfg.lib.securityHeaders} add_header WWW-Authenticate 'Bearer realm="swarm"' always; return 401; } diff --git a/nix/module-eval/core-toggle.nix b/nix/module-eval/core-toggle.nix index c2c99f8ec..aabeac254 100644 --- a/nix/module-eval/core-toggle.nix +++ b/nix/module-eval/core-toggle.nix @@ -499,22 +499,18 @@ let # with an error that says nothing about the session; only a request that # asks for `text/html` gets the login. The `/` clause is the control: the # page route still redirects, so a pass means the two routes differ. - # Each answer carries the gateway's security headers, which a location - # (or `if`) with an `add_header` of its own would otherwise drop. name = "the controller API answers a refused bearer caller or fetch 401 and a page request the login"; ok = let l = allLocal.services.nginx.virtualHosts."t.local".locations; api = l."/api/".extraConfig; refused = l."@swarm_api_unauthorized".extraConfig; - sec = allLocal.services.hyperhive.gateway.lib.securityHeaders; in lib.hasInfix "error_page 401 = @swarm_api_unauthorized;" api && !(lib.hasInfix "=302" api) && lib.hasInfix ''proxy_set_header Authorization "";'' api - && lib.hasInfix "if ($http_authorization) {\n ${sec}\n add_header WWW-Authenticate 'Bearer realm=\"swarm\"' always;\n return 401;\n}" refused + && lib.hasInfix "if ($http_authorization) {\n add_header WWW-Authenticate 'Bearer realm=\"swarm\"' always;\n return 401;\n}" refused && lib.hasInfix "if ($http_accept ~* \"text/html\") {\n return 302 https://auth.t.local/?rd=$target_url;\n}" refused - && lib.hasPrefix sec refused && lib.hasInfix "}\nadd_header WWW-Authenticate 'Bearer realm=\"swarm\"' always;\nreturn 401;" refused && lib.hasInfix "error_page 401 =302 https://auth.t.local/" l."/".extraConfig; }