Unary server interceptor which validates if the RPC contains call credentials which match `perRPCCredsData
(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler)
| 192 | // Unary server interceptor which validates if the RPC contains call credentials |
| 193 | // which match `perRPCCredsData |
| 194 | func callCredsValidatingServerInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { |
| 195 | md, ok := metadata.FromIncomingContext(ctx) |
| 196 | if !ok { |
| 197 | return nil, status.Error(codes.PermissionDenied, "didn't find metadata in context") |
| 198 | } |
| 199 | for k, want := range perRPCCredsData { |
| 200 | got, ok := md[k] |
| 201 | if !ok { |
| 202 | return ctx, status.Errorf(codes.PermissionDenied, "didn't find call creds key %v in context", k) |
| 203 | } |
| 204 | if got[0] != want { |
| 205 | return ctx, status.Errorf(codes.PermissionDenied, "for key %v, got value %v, want %v", k, got, want) |
| 206 | } |
| 207 | } |
| 208 | return handler(ctx, req) |
| 209 | } |
| 210 | |
| 211 | // makeTLSCreds is a test helper which creates a TLS based transport credentials |
| 212 | // from files specified in the arguments. |
nothing calls this directly
no test coverage detected