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
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Command archie-gateway hosts the Gateway Service's gRPC contract.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"path/filepath"
|
|
"syscall"
|
|
|
|
"github.com/samcharles93/archie-core/internal/app/archied"
|
|
)
|
|
|
|
func main() { os.Exit(run()) }
|
|
|
|
func run() int {
|
|
base, err := os.UserConfigDir()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
var options archied.GatewayOptions
|
|
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()
|
|
if err := archied.RunGateway(ctx, options); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|