X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e8d1a643cdbc3a5f4c0e5c745da58d9f7e1248d8..22f9af1104fa45e95ef3cd8b5a770fc0b9ed0fd3:/lib/controller/federation.go diff --git a/lib/controller/federation.go b/lib/controller/federation.go index aceaba8087..e7d6e29b88 100644 --- a/lib/controller/federation.go +++ b/lib/controller/federation.go @@ -94,20 +94,12 @@ func (h *Handler) setupProxyRemoteCluster(next http.Handler) http.Handler { wfHandler := &genericFederatedRequestHandler{next, h, wfRe, nil} containersHandler := &genericFederatedRequestHandler{next, h, containersRe, nil} - containerRequestsHandler := &genericFederatedRequestHandler{next, h, containerRequestsRe, - []federatedRequestDelegate{remoteContainerRequestCreate}} - collectionsRequestsHandler := &genericFederatedRequestHandler{next, h, collectionsRe, - []federatedRequestDelegate{fetchRemoteCollectionByUUID, fetchRemoteCollectionByPDH}} linksRequestsHandler := &genericFederatedRequestHandler{next, h, linksRe, nil} mux.Handle("/arvados/v1/workflows", wfHandler) mux.Handle("/arvados/v1/workflows/", wfHandler) mux.Handle("/arvados/v1/containers", containersHandler) mux.Handle("/arvados/v1/containers/", containersHandler) - mux.Handle("/arvados/v1/container_requests", containerRequestsHandler) - mux.Handle("/arvados/v1/container_requests/", containerRequestsHandler) - mux.Handle("/arvados/v1/collections", collectionsRequestsHandler) - mux.Handle("/arvados/v1/collections/", collectionsRequestsHandler) mux.Handle("/arvados/v1/links", linksRequestsHandler) mux.Handle("/arvados/v1/links/", linksRequestsHandler) mux.Handle("/", next) @@ -129,8 +121,6 @@ func (h *Handler) setupProxyRemoteCluster(next http.Handler) http.Handler { mux.ServeHTTP(w, req) }) - - return mux } type CurrentUser struct { @@ -224,10 +214,9 @@ VALUES ($1, $2, CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + INTERVAL '2 weeks', $3, } return &arvados.APIClientAuthorization{ - UUID: uuid, - APIToken: token, - ExpiresAt: "", - Scopes: scopes}, nil + UUID: uuid, + APIToken: token, + Scopes: scopes}, nil } // Extract the auth token supplied in req, and replace it with a @@ -263,17 +252,20 @@ func (h *Handler) saltAuthToken(req *http.Request, remote string) (updatedReq *h return updatedReq, nil } + ctxlog.FromContext(req.Context()).Debugf("saltAuthToken: cluster %s token %s remote %s", h.Cluster.ClusterID, creds.Tokens[0], remote) token, err := auth.SaltToken(creds.Tokens[0], remote) - if err == auth.ErrObsoleteToken { - // If the token exists in our own database, salt it - // for the remote. Otherwise, assume it was issued by - // the remote, and pass it through unmodified. + if err == auth.ErrObsoleteToken || err == auth.ErrTokenFormat { + // If the token exists in our own database for our own + // user, salt it for the remote. Otherwise, assume it + // was issued by the remote, and pass it through + // unmodified. currentUser, ok, err := h.validateAPItoken(req, creds.Tokens[0]) if err != nil { return nil, err - } else if !ok { - // Not ours; pass through unmodified. + } else if !ok || strings.HasPrefix(currentUser.UUID, remote) { + // Unknown, or cached + belongs to remote; + // pass through unmodified. token = creds.Tokens[0] } else { // Found; make V2 version and salt it.