Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip admin and change oidc user not found message more readable #21061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/pkg/oidc/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"context"
"encoding/json"
"fmt"
"strings"
"sync"

"github.com/goharbor/harbor/src/common/utils"
Expand Down Expand Up @@ -86,6 +87,9 @@
func (dm *defaultManager) VerifySecret(ctx context.Context, username string, secret string) (*UserInfo, error) {
log.Debugf("Verifying the secret for user: %s", username)
oidcUser, err := dm.metaDao.GetByUsername(ctx, username)
if strings.Contains(err.Error(), "no row found") {
return nil, fmt.Errorf("oidc user: %v not found", username)
}

Check warning on line 92 in src/pkg/oidc/secret.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/oidc/secret.go#L90-L92

Added lines #L90 - L92 were not covered by tests
if err != nil {
return nil, fmt.Errorf("failed to get oidc user info, error: %v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions src/server/middleware/security/oidc_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
return nil
}

if username == "admin" {
return nil
}

Check warning on line 68 in src/server/middleware/security/oidc_cli.go

View check run for this annotation

Codecov / codecov/patch

src/server/middleware/security/oidc_cli.go#L67-L68

Added lines #L67 - L68 were not covered by tests

info, err := oidc.VerifySecret(ctx, username, secret)
if err != nil {
logger.Errorf("failed to verify secret, username: %s, error: %v", username, err)
Expand Down
Loading