-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21061 +/- ##
===========================================
+ Coverage 45.36% 66.08% +20.71%
===========================================
Files 244 1049 +805
Lines 13333 114661 +101328
Branches 2719 2867 +148
===========================================
+ Hits 6049 75768 +69719
- Misses 6983 34749 +27766
- Partials 301 4144 +3843
Flags with carried forward coverage won't be shown. Click here to find out more.
|
4ba168e
to
06d5924
Compare
+1, this would be very helpful |
+1 |
93cfdc4
to
c6ce7bc
Compare
fixes goharbor#21041 Signed-off-by: stonezdj <stone.zhang@broadcom.com>
c6ce7bc
to
58b9680
Compare
+1 |
user, err2 := uctl.GetByName(ctx, username) | ||
// skip to log the error if the user is the admin user | ||
if err2 == nil && user != nil && user.UserID == 1 { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log at debug level for admin users as this might be expected
logger.Debugf("OIDC verification failed for admin user %s: %v", username, err)
@@ -86,6 +87,9 @@ var m SecretManager = &defaultManager{ | |||
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") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking error strings is fragile. Would not be better to:
- Use proper error types or sentinel errors
- Check if the error implements a specific interface
fixes #21041
verified in local env
Thank you for contributing to Harbor!
Comprehensive Summary of your change
Issue being fixed
Fixes #(issue)
Please indicate you've done the following: