mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-27 02:58:05 +01:00
Do not check security context in Get of user controller
This commit make sure when security context is not found the `Get` function in user controller should not return error. Because this func will be called by security middleware, at which point of time the security context is not generated. Additionally, checking security context is not necessary because the permission checking is already done in the API handler layer. fixes #15535 Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
04cd65d179
commit
884da19414
@ -16,7 +16,7 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
commonmodels "github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/security"
|
||||
@ -148,10 +148,7 @@ func (c *controller) Get(ctx context.Context, id int, opt *Option) (*models.User
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sctx, ok := security.FromContext(ctx)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("can't find security context")
|
||||
}
|
||||
sctx, _ := security.FromContext(ctx)
|
||||
lsc, ok := sctx.(*local.SecurityContext)
|
||||
if ok && lsc.User() != nil && lsc.User().UserID == id {
|
||||
u.AdminRoleInAuth = lsc.User().AdminRoleInAuth
|
||||
|
Loading…
Reference in New Issue
Block a user