Update the URL checking logic of auth proxy security generator (#11180)

As we don't support bearer token in Harbor 2.0, the URL checking logic in auth proxy security generator should be updated

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开) 2020-03-25 01:19:11 +08:00 committed by GitHub
parent 8984979bd2
commit d05817c8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -38,7 +38,7 @@ func (a *authProxy) Generate(req *http.Request) security.Context {
return nil
}
// only support docker login
if req.URL.Path != "/service/token" {
if !strings.HasPrefix(req.URL.Path, "/v2") {
return nil
}
proxyUserName, proxyPwd, ok := req.BasicAuth()

View File

@ -60,7 +60,7 @@ func TestAuthProxy(t *testing.T) {
})
// No onboard
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1/service/token", nil)
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1/v2", nil)
require.Nil(t, err)
req = req.WithContext(lib.WithAuthMode(req.Context(), common.HTTPAuth))
req.SetBasicAuth("tokenreview$administrator@vsphere.local", "reviEwt0k3n")