photoncloud-monorepo/nix/modules/k8shost.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
2 KiB
Nix

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