mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-05 07:27:50 +01:00
donot return password of target
This commit is contained in:
parent
d8a0e01214
commit
488e19f514
@ -147,17 +147,7 @@ func (t *TargetAPI) Get() {
|
|||||||
t.CustomAbort(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
t.CustomAbort(http.StatusNotFound, http.StatusText(http.StatusNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The reason why the password is returned is that when user just wants to
|
target.Password = ""
|
||||||
// modify other fields of target he does not need to input the password again.
|
|
||||||
// The security issue can be fixed by enable https.
|
|
||||||
if len(target.Password) != 0 {
|
|
||||||
pwd, err := utils.ReversibleDecrypt(target.Password, t.secretKey)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failed to decrypt password: %v", err)
|
|
||||||
t.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
|
|
||||||
}
|
|
||||||
target.Password = pwd
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Data["json"] = target
|
t.Data["json"] = target
|
||||||
t.ServeJSON()
|
t.ServeJSON()
|
||||||
@ -173,16 +163,7 @@ func (t *TargetAPI) List() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
if len(target.Password) == 0 {
|
target.Password = ""
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
str, err := utils.ReversibleDecrypt(target.Password, t.secretKey)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failed to decrypt password: %v", err)
|
|
||||||
t.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
|
|
||||||
}
|
|
||||||
target.Password = str
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Data["json"] = targets
|
t.Data["json"] = targets
|
||||||
|
Loading…
Reference in New Issue
Block a user