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.
20 lines
807 B
Go
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...)
|
|
}
|