Skip robot account for oidc_cli middleware (#18317)

Fixes #15253

Signed-off-by: stonezdj <daojunz@vmware.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2023-03-09 15:41:08 +08:00 committed by GitHub
parent 5a065d1cd8
commit 5c9ce836cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,7 @@ import (
"github.com/goharbor/harbor/src/common/security/local"
"github.com/goharbor/harbor/src/controller/user"
"github.com/goharbor/harbor/src/lib"
"github.com/goharbor/harbor/src/lib/config"
"github.com/goharbor/harbor/src/lib/log"
"github.com/goharbor/harbor/src/pkg/oidc"
)
@ -57,6 +58,11 @@ func (o *oidcCli) Generate(req *http.Request) security.Context {
if !o.valid(req) {
return nil
}
if strings.HasPrefix(username, config.RobotPrefix(ctx)) {
return nil
}
info, err := oidc.VerifySecret(ctx, username, secret)
if err != nil {
logger.Errorf("failed to verify secret, username: %s, error: %v", username, err)