mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
Give meaningful messages when retag forbided
Signed-off-by: cd1989 <chende@caicloud.io>
This commit is contained in:
parent
9100dfdb5f
commit
caf07a96fe
@ -61,9 +61,9 @@ func (b *BaseAPI) HandleUnauthorized() {
|
||||
}
|
||||
|
||||
// HandleForbidden ...
|
||||
func (b *BaseAPI) HandleForbidden(username string) {
|
||||
log.Infof("forbidden: %s", username)
|
||||
b.RenderError(http.StatusForbidden, "")
|
||||
func (b *BaseAPI) HandleForbidden(text string) {
|
||||
log.Infof("forbidden: %s", text)
|
||||
b.RenderError(http.StatusForbidden, text)
|
||||
}
|
||||
|
||||
// HandleBadRequest ...
|
||||
|
@ -480,14 +480,14 @@ func (ra *RepositoryAPI) Retag() {
|
||||
// Check whether use has read permission to source project
|
||||
if !ra.SecurityCtx.HasReadPerm(srcImage.Project) {
|
||||
log.Errorf("user has no read permission to project '%s'", srcImage.Project)
|
||||
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
|
||||
ra.HandleForbidden(fmt.Sprintf("%s has no read permission to project %s", ra.SecurityCtx.GetUsername(), srcImage.Project))
|
||||
return
|
||||
}
|
||||
|
||||
// Check whether user has write permission to target project
|
||||
if !ra.SecurityCtx.HasWritePerm(project) {
|
||||
log.Errorf("user has no write permission to project '%s'", project)
|
||||
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
|
||||
ra.HandleForbidden(fmt.Sprintf("%s has no write permission to project %s", ra.SecurityCtx.GetUsername(), project))
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user