feat(gateway): authenticate the gRPC contract and allow off-loopback listeners

The Gateway had no transport boundary: RunGateway refused any non-loopback
listen address and serveGateway registered no interceptor, so archie-ui was
colocation-only while the State Store already had a token-authenticated
equivalent.

gatewayrpc gains a gateway-token metadata credential with constant-time
comparison and both unary and stream interceptors on each side. Stream
coverage is required here and not in staterpc: the Gateway's Stream RPC is
server-streaming. Dial fails closed on a non-loopback target with no token,
mirroring staterpc.Dial. gatewayServerOpts applies the same rule server-side:
loopback stays insecure, non-loopback requires a token, malformed errors.

The daemon resolves [services.gateway].target_token then GATEWAY_TOKEN;
archie-ui passes the token its config projection already carried, so a
distributed dashboard is now possible.

Closes: archie-core-juqx
This commit is contained in:
sam committed 2026-09-09 00:27:03 +10:00
1 parent 73d371614b
commit 0ec4ececd5
13 files changed
+453 -33

No files matched your search

+1
View File
@@ -25,6 +25,7 @@ func run() int {
flag.StringVar(&options.Config, "config", filepath.Join(base, "archie", "config.toml"), "configuration file or directory")
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
flag.StringVar(&options.Listen, "listen", "127.0.0.1:8585", "gateway gRPC listen address")
flag.StringVar(&options.Token, "token", "", "Bearer [REDACTED] required for a non-loopback listener (defaults to [services.gateway].target_token)")
flag.Parse()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()