MCPcopy Create free account
hub / github.com/couchbase/cbft / verifyRPCAuth

Function verifyRPCAuth

grpc_auth.go:191–216  ·  view source on GitHub ↗
(ctx context.Context, indexName string, req interface{})

Source from the content-addressed store, hash-verified

189}
190
191func 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}

Callers 1

SearchMethod · 0.85

Calls 1

extractMetaHeaderFunction · 0.85

Tested by

no test coverage detected