mirror of
https://github.com/goharbor/harbor.git
synced 2024-08-20 02:52:49 +02:00
update
This commit is contained in:
parent
8191f4a476
commit
6aa3e51b40
|
@ -18,7 +18,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
beegoctx "github.com/astaxie/beego/context"
|
||||
"github.com/vmware/harbor/src/common/models"
|
||||
|
@ -77,11 +76,6 @@ func SecurityFilter(ctx *beegoctx.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(req.URL.RequestURI(), "/api/") &&
|
||||
!strings.HasPrefix(req.URL.RequestURI(), "/service/token") {
|
||||
return
|
||||
}
|
||||
|
||||
// add security context and project manager to request context
|
||||
for _, modifier := range reqCtxModifiers {
|
||||
if modifier.Modify(ctx) {
|
||||
|
|
|
@ -88,22 +88,8 @@ func TestSecurityFilter(t *testing.T) {
|
|||
assert.Nil(t, securityContext(ctx))
|
||||
assert.Nil(t, projectManager(ctx))
|
||||
|
||||
// the pattern of request does not need security check
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1/static/index.html", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", req)
|
||||
}
|
||||
|
||||
ctx, err = newContext(req)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to crate context: %v", err)
|
||||
}
|
||||
SecurityFilter(ctx)
|
||||
assert.Nil(t, securityContext(ctx))
|
||||
assert.Nil(t, projectManager(ctx))
|
||||
|
||||
// the pattern of request needs security check
|
||||
req, err = http.NewRequest(http.MethodGet,
|
||||
req, err := http.NewRequest(http.MethodGet,
|
||||
"http://127.0.0.1/api/projects/", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create request: %v", req)
|
||||
|
|
Loading…
Reference in New Issue
Block a user