Files
archie/internal/infrastructure/gatewayrpc/auth.go
T
sam 53c95038de feat(rpc): mTLS between services from operator-issued certificates
Replace the service bearer tokens with [tls] ca_file and cert_dir. Caller
identity comes from the verified certificate, not metadata. Without TLS,
services listen and dial on loopback only. Task containers get only the CA
and keep their grant.
2026-10-16 02:37:51 +11:00

20 lines
807 B
Go

package gatewayrpc
import (
"context"
"google.golang.org/grpc"
"github.com/samcharles93/archie-core/internal/infrastructure/rpcidentity"
)
// unaryPrincipal forwards the context's principal on every unary call.
func unaryPrincipal(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return invoker(rpcidentity.Outgoing(ctx, "gateway-client"), method, req, reply, cc, opts...)
}
// streamPrincipal forwards the context's principal on every stream.
func streamPrincipal(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
return streamer(rpcidentity.Outgoing(ctx, "gateway-client"), desc, cc, method, opts...)
}