提交 4d9268be 编写于 作者: LinuxSuRen's avatar LinuxSuRen

Fix devops artifact cannot be download due to auth checking

Signed-off-by: LinuxSuRen's avatarrick <rick@jenkins-zh.cn>
上级 dab0842a
......@@ -688,6 +688,9 @@ func AddJenkinsToContainer(webservice *restful.WebService, devopsClient devops.I
return err
}
parse.Path = strings.Trim(parse.Path, "/")
// this API does not belong any kind of auth scope, it should be removed in the future version
// see also pkg/apiserver/request/requestinfo.go
// Deprecated: Please use /devops/{devops}/jenkins/{path:*} instead
webservice.Route(webservice.GET("/jenkins/{path:*}").
Param(webservice.PathParameter("path", "Path stands for any suffix path.")).
To(func(request *restful.Request, response *restful.Response) {
......@@ -701,6 +704,22 @@ func AddJenkinsToContainer(webservice *restful.WebService, devopsClient devops.I
}).
Returns(http.StatusOK, RespOK, nil).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DevOpsJenkinsTag}))
webservice.Route(webservice.GET("/devops/{devops}/jenkins/{path:*}").
Param(webservice.PathParameter("path", "Path stands for any suffix path.")).
Param(webservice.PathParameter("devops", "DevOps project's ID, e.g. project-RRRRAzLBlLEm")).
To(func(request *restful.Request, response *restful.Response) {
u := request.Request.URL
devops := request.PathParameter("devops")
u.Host = parse.Host
u.Scheme = parse.Scheme
jenkins.SetBasicBearTokenHeader(&request.Request.Header)
u.Path = strings.Replace(request.Request.URL.Path, fmt.Sprintf("/kapis/%s/%s/devops/%s/jenkins",
GroupVersion.Group, GroupVersion.Version, devops), "", 1)
httpProxy := proxy.NewUpgradeAwareHandler(u, http.DefaultTransport, false, false, &errorResponder{})
httpProxy.ServeHTTP(response, request.Request)
}).
Returns(http.StatusOK, RespOK, nil).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.DevOpsJenkinsTag}))
return nil
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册