Return 403 when trying to push artifacts into the proxy cache project to avoid the retrying in the docker client

Return 403 when trying to push artifacts into the proxy cache project to avoid the retrying in the docker client
fixes #12731

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2020-08-16 21:22:22 +08:00
parent 3b7a2e11b4
commit a73742c0a7
2 changed files with 2 additions and 3 deletions

View File

@ -184,7 +184,7 @@ func DisableBlobAndManifestUploadMiddleware() func(http.Handler) http.Handler {
}
if isProxyProject(p) && !isProxySession(ctx) {
httpLib.SendError(w,
errors.MethodNotAllowedError(
errors.DeniedError(
errors.Errorf("can not push artifact to a proxy project: %v", p.Name)))
return
}

View File

@ -77,6 +77,7 @@ func RegisterRoutes() {
root.NewRoute().
Method(http.MethodPost).
Path("/*/blobs/uploads").
Middleware(repoproxy.DisableBlobAndManifestUploadMiddleware()).
Middleware(quota.PostInitiateBlobUploadMiddleware()).
Middleware(blob.PostInitiateBlobUploadMiddleware()).
Handler(proxy)
@ -84,13 +85,11 @@ func RegisterRoutes() {
root.NewRoute().
Method(http.MethodPatch).
Path("/*/blobs/uploads/:session_id").
Middleware(repoproxy.DisableBlobAndManifestUploadMiddleware()).
Middleware(blob.PatchBlobUploadMiddleware()).
Handler(proxy)
root.NewRoute().
Method(http.MethodPut).
Path("/*/blobs/uploads/:session_id").
Middleware(repoproxy.DisableBlobAndManifestUploadMiddleware()).
Middleware(quota.PutBlobUploadMiddleware()).
Middleware(blob.PutBlobUploadMiddleware()).
Handler(proxy)