photoncloud-monorepo/nix/modules/prismnet.nix
centra d2149b6249 fix(lightningstor): Fix SigV4 canonicalization for AWS S3 auth
- Replace form_urlencoded with RFC 3986 compliant URI encoding
- Implement aws_uri_encode() matching AWS SigV4 spec exactly
- Unreserved chars (A-Z,a-z,0-9,-,_,.,~) not encoded
- All other chars percent-encoded with uppercase hex
- Preserve slashes in paths, encode in query params
- Normalize empty paths to '/' per AWS spec
- Fix test expectations (body hash, HMAC values)
- Add comprehensive SigV4 signature determinism test

This fixes the canonicalization mismatch that caused signature
validation failures in T047. Auth can now be enabled for production.

Refs: T058.S1
2025-12-12 06:23:46 +09:00

76 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.prismnet;
in
{
options.services.prismnet = {
enable = lib.mkEnableOption "prismnet service";
port = lib.mkOption {
type = lib.types.port;
default = 5000;
description = "Port for prismnet API";
};
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/prismnet";
description = "Data directory for prismnet";
};
settings = lib.mkOption {
type = lib.types.attrs;
default = {};
description = "Additional configuration settings";
};
package = lib.mkOption {
type = lib.types.package;
default = pkgs.prismnet-server or (throw "prismnet-server package not found");
description = "Package to use for prismnet";
};
};
config = lib.mkIf cfg.enable {
# Create system user
users.users.prismnet = {
isSystemUser = true;
group = "prismnet";
description = "PrismNet service user";
home = cfg.dataDir;
};
users.groups.prismnet = {};
# Create systemd service
systemd.services.prismnet = {
description = "PrismNet Software-Defined Networking Service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "iam.service" "flaredb.service" ];
requires = [ "iam.service" "flaredb.service" ];
serviceConfig = {
Type = "simple";
User = "prismnet";
Group = "prismnet";
Restart = "on-failure";
RestartSec = "10s";
# State directory management
StateDirectory = "prismnet";
StateDirectoryMode = "0750";
# Security hardening
NoNewPrivileges = true;
PrivateTmp = true;
ProtectSystem = "strict";
ProtectHome = true;
ReadWritePaths = [ cfg.dataDir ];
# Start command
ExecStart = "${cfg.package}/bin/prismnet-server --port ${toString cfg.port} --data-dir ${cfg.dataDir}";
};
};
};
}