Merge pull request #14653 from reasonerjt/no-oidc-admin

Do not get OIDC info for admin user
This commit is contained in:
Wenkai Yin(尹文开) 2021-04-15 09:50:43 +08:00 committed by GitHub
commit e6b2abfebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/goharbor/harbor/src/common/security"
"github.com/goharbor/harbor/src/common/security/local"
"github.com/goharbor/harbor/src/lib/errors"
"github.com/goharbor/harbor/src/lib/q"
"github.com/goharbor/harbor/src/pkg/oidc"
"github.com/goharbor/harbor/src/pkg/user"
@ -102,7 +103,7 @@ func (c *controller) Get(ctx context.Context, id int, opt *Option) (*models.User
if opt != nil && opt.WithOIDCInfo {
oidcMeta, err := c.oidcMetaMgr.GetByUserID(ctx, id)
if err != nil {
return nil, err
return nil, errors.UnknownError(err)
}
u.OIDCUserMeta = oidcMeta
}

View File

@ -224,7 +224,7 @@ func (u *usersAPI) getUserByID(ctx context.Context, id int) (*models.UserResp, e
}
opt := &user.Option{
WithOIDCInfo: auth == common.OIDCAuth,
WithOIDCInfo: auth == common.OIDCAuth && id > 1, // Super user is authenticated via DB
}
us, err := u.ctl.Get(ctx, id, opt)