mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +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 ...
|
||||
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