(ctx context.Context, indexName string, req interface{})
| 189 | } |
| 190 | |
| 191 | func verifyRPCAuth(ctx context.Context, indexName string, req interface{}) error { |
| 192 | if _, err := extractMetaHeader(ctx, rpcClusterActionKey); err == nil { |
| 193 | return nil |
| 194 | } |
| 195 | |
| 196 | var authHandler gRPCAuthHandler |
| 197 | if aw := ctx.Value(gRPCAuthHandlerKey); aw != nil { |
| 198 | authHandler = aw.(gRPCAuthHandler) |
| 199 | } |
| 200 | |
| 201 | if authHandler == nil { |
| 202 | return fmt.Errorf("grpc_auth: invalid authHandler") |
| 203 | } |
| 204 | |
| 205 | v, err := authHandler( |
| 206 | &rpcRequestParser{indexName: indexName, |
| 207 | request: req}) |
| 208 | if err != nil { |
| 209 | return fmt.Errorf("grpc_auth: auth err: %v", err) |
| 210 | } |
| 211 | if !v { |
| 212 | return fmt.Errorf("grpc_auth: permission denied") |
| 213 | } |
| 214 | |
| 215 | return nil |
| 216 | } |
no test coverage detected