X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/23ddce7f83a4ab2e39b5910766f54aafb7b5a99d..903b27b2f4b8b00c11525ff6c2f4eb383709d074:/lib/controller/fed_generic.go diff --git a/lib/controller/fed_generic.go b/lib/controller/fed_generic.go index 0630217b6e..9c8b1614bc 100644 --- a/lib/controller/fed_generic.go +++ b/lib/controller/fed_generic.go @@ -17,10 +17,20 @@ import ( "git.curoverse.com/arvados.git/sdk/go/httpserver" ) +type federatedRequestDelegate func( + h *genericFederatedRequestHandler, + effectiveMethod string, + clusterId *string, + uuid string, + remainder string, + w http.ResponseWriter, + req *http.Request) bool + type genericFederatedRequestHandler struct { - next http.Handler - handler *Handler - matcher *regexp.Regexp + next http.Handler + handler *Handler + matcher *regexp.Regexp + delegates []federatedRequestDelegate } func (h *genericFederatedRequestHandler) remoteQueryUUIDs(w http.ResponseWriter, @@ -130,7 +140,7 @@ func (h *genericFederatedRequestHandler) handleMultiClusterQuery(w http.Response if op == "in" { if rhs, ok := filter[2].([]interface{}); ok { for _, i := range rhs { - if u, ok := i.(string); ok { + if u, ok := i.(string); ok && len(u) == 27 { *clusterId = u[0:5] queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u) expectCount += 1 @@ -138,7 +148,7 @@ func (h *genericFederatedRequestHandler) handleMultiClusterQuery(w http.Response } } } else if op == "=" { - if u, ok := filter[2].(string); ok { + if u, ok := filter[2].(string); ok && len(u) == 27 { *clusterId = u[0:5] queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u) expectCount += 1 @@ -285,6 +295,17 @@ func (h *genericFederatedRequestHandler) ServeHTTP(w http.ResponseWriter, req *h return } + var uuid string + if len(m[1]) > 0 { + // trim leading slash + uuid = m[1][1:] + } + for _, d := range h.delegates { + if d(h, effectiveMethod, &clusterId, uuid, m[3], w, req) { + return + } + } + if clusterId == "" || clusterId == h.handler.Cluster.ClusterID { h.next.ServeHTTP(w, req) } else {