WithForwardedAuth returns a grpc.CallOption with authentication from the incoming context ctx.
(ctx context.Context, allowInsecure bool)
| 38 | |
| 39 | // WithForwardedAuth returns a grpc.CallOption with authentication from the incoming context ctx. |
| 40 | func WithForwardedAuth(ctx context.Context, allowInsecure bool) (grpc.CallOption, error) { |
| 41 | md := FromIncomingContext(ctx) |
| 42 | if md.AuthType == "" || md.AuthValue == "" { |
| 43 | return nil, errUnauthenticated.New() |
| 44 | } |
| 45 | md.AllowInsecure = allowInsecure |
| 46 | return grpc.PerRPCCredentials(md), nil |
| 47 | } |
| 48 | |
| 49 | const requestIDKey = "x-request-id" |
| 50 |