mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Add password mask to /get-ldaps and /get-ldap APIs
This commit is contained in:
parent
a193ceb33d
commit
438c999e11
@ -100,7 +100,7 @@ func (c *ApiController) GetLdapUsers() {
|
|||||||
func (c *ApiController) GetLdaps() {
|
func (c *ApiController) GetLdaps() {
|
||||||
owner := c.Input().Get("owner")
|
owner := c.Input().Get("owner")
|
||||||
|
|
||||||
c.ResponseOk(object.GetLdaps(owner))
|
c.ResponseOk(object.GetMaskedLdaps(object.GetLdaps(owner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLdap
|
// GetLdap
|
||||||
@ -116,7 +116,7 @@ func (c *ApiController) GetLdap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, name := util.GetOwnerAndNameFromId(id)
|
_, name := util.GetOwnerAndNameFromId(id)
|
||||||
c.ResponseOk(object.GetLdap(name))
|
c.ResponseOk(object.GetMaskedLdap(object.GetLdap(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLdap
|
// AddLdap
|
||||||
|
@ -103,6 +103,37 @@ func GetLdap(id string) (*Ldap, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMaskedLdap(ldap *Ldap, errs ...error) (*Ldap, error) {
|
||||||
|
if len(errs) > 0 && errs[0] != nil {
|
||||||
|
return nil, errs[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if ldap == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if ldap.Password != "" {
|
||||||
|
ldap.Password = "***"
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldap, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMaskedLdaps(ldaps []*Ldap, errs ...error) ([]*Ldap, error) {
|
||||||
|
if len(errs) > 0 && errs[0] != nil {
|
||||||
|
return nil, errs[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for _, ldap := range ldaps {
|
||||||
|
ldap, err = GetMaskedLdap(ldap)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ldaps, nil
|
||||||
|
}
|
||||||
|
|
||||||
func UpdateLdap(ldap *Ldap) (bool, error) {
|
func UpdateLdap(ldap *Ldap) (bool, error) {
|
||||||
if l, err := GetLdap(ldap.Id); err != nil {
|
if l, err := GetLdap(ldap.Id); err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user