mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 04:35:16 +01:00
Merge pull request #6470 from cd1989/retag-problem
Give meaningful error messages when retag is forbidden
This commit is contained in:
commit
bcd6947fcc
@ -61,9 +61,9 @@ func (b *BaseAPI) HandleUnauthorized() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HandleForbidden ...
|
// HandleForbidden ...
|
||||||
func (b *BaseAPI) HandleForbidden(username string) {
|
func (b *BaseAPI) HandleForbidden(text string) {
|
||||||
log.Infof("forbidden: %s", username)
|
log.Infof("forbidden: %s", text)
|
||||||
b.RenderError(http.StatusForbidden, "")
|
b.RenderError(http.StatusForbidden, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleBadRequest ...
|
// HandleBadRequest ...
|
||||||
|
@ -480,14 +480,14 @@ func (ra *RepositoryAPI) Retag() {
|
|||||||
// Check whether use has read permission to source project
|
// Check whether use has read permission to source project
|
||||||
if !ra.SecurityCtx.HasReadPerm(srcImage.Project) {
|
if !ra.SecurityCtx.HasReadPerm(srcImage.Project) {
|
||||||
log.Errorf("user has no read permission to project '%s'", 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether user has write permission to target project
|
// Check whether user has write permission to target project
|
||||||
if !ra.SecurityCtx.HasWritePerm(project) {
|
if !ra.SecurityCtx.HasWritePerm(project) {
|
||||||
log.Errorf("user has no write permission to project '%s'", 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user