[deploy] Sockets: services.ianitor.edge.proxySocket (Caddy beside Ianitor reaches edge on a 0660 socket of the ianitor-proxy group) and ui.socket (control's UI socket, the proof trusted only there); the Configuration_Server patch, beside-caddy.md and api.md follow; a VM test for both
This commit is contained in:
@@ -226,6 +226,56 @@ in
|
||||
server.fail("find /var/lib/ianitor -name 'domi-root.key' | grep -q .")
|
||||
'';
|
||||
|
||||
# G14 option b and the proxy socket (phase 4): another local user can neither open control's
|
||||
# UI socket nor use the proof over the loopback port; the front proxy's socket is for the
|
||||
# ianitor-proxy group only.
|
||||
vm-sockets = pkgs.testers.runNixOSTest {
|
||||
name = "ianitor-sockets";
|
||||
nodes.server = {
|
||||
imports = [ server ];
|
||||
services.ianitor.edge.proxySocket = { enable = true; users = [ "front" ]; };
|
||||
services.ianitor.ui.hostname = "ui.test";
|
||||
users.users.front.isNormalUser = true;
|
||||
users.users.mallory.isNormalUser = true;
|
||||
};
|
||||
testScript = helpers + ''
|
||||
start_all()
|
||||
t = setup(server)
|
||||
install_intermediate(server, t)
|
||||
server.succeed("test -S /run/ianitor-control/ui.sock")
|
||||
assert server.succeed("stat -c %a /run/ianitor-control/ui.sock").strip() == "660"
|
||||
assert server.succeed("stat -c %a /run/ianitor-control").strip() == "750"
|
||||
# Another local user cannot reach the UI socket ...
|
||||
server.fail("runuser -u mallory -- curl -sf -m 5 --unix-socket /run/ianitor-control/ui.sock http://localhost/api/v1/overview")
|
||||
# ... nor sign in over the loopback port, even with the real proof (read here as root).
|
||||
proof = server.succeed("cat /run/ianitor-proof/ui-proof").strip()
|
||||
code = server.succeed(
|
||||
"runuser -u mallory -- curl -s -o /dev/null -w '%{http_code}' -H 'Remote-User: mallory' "
|
||||
+ "-H 'X-Ianitor-Proof: " + proof + "' http://127.0.0.1:7878/api/v1/overview"
|
||||
).strip()
|
||||
assert code == "401", code
|
||||
# The same over the socket, as edge (group ianitor): signed in.
|
||||
code = server.succeed(
|
||||
"runuser -u ianitor-edge -- curl -s -o /dev/null -w '%{http_code}' -H 'Host: ui.test' "
|
||||
+ "-H 'Remote-User: mark' -H 'X-Ianitor-Proof: " + proof + "' "
|
||||
+ "--unix-socket /run/ianitor-control/ui.sock http://ui.test/api/v1/overview"
|
||||
).strip()
|
||||
assert code == "200", code
|
||||
|
||||
# The front proxy's socket: the front user may connect, mallory may not.
|
||||
r = api(server, t, "POST", "/hosts", {"host": {
|
||||
"hostname": "app.test", "upstreams": ["http://127.0.0.1:8000"], "tls": "domi", "auth": "none"}})
|
||||
assert wait_apply(server, t, r["apply"]["id"])["state"] == "kept"
|
||||
server.wait_until_succeeds("test -S /run/ianitor-proxy/edge.sock")
|
||||
assert server.succeed("stat -c '%a %G' /run/ianitor-proxy/edge.sock").strip() == "660 ianitor-proxy"
|
||||
code = server.succeed(
|
||||
"runuser -u front -- curl -s -o /dev/null -w '%{http_code}' --unix-socket /run/ianitor-proxy/edge.sock http://app.test/"
|
||||
).strip()
|
||||
assert code == "200", code
|
||||
server.fail("runuser -u mallory -- curl -sf -m 5 --unix-socket /run/ianitor-proxy/edge.sock http://app.test/")
|
||||
'';
|
||||
};
|
||||
|
||||
vm-control-loopback = pkgs.testers.runNixOSTest {
|
||||
name = "ianitor-control-loopback";
|
||||
nodes.server = server;
|
||||
|
||||
Reference in New Issue
Block a user