fix(keystone): show ldap url (#23173)

This commit is contained in:
屈轩
2025-08-26 14:28:32 +08:00
committed by GitHub
parent af9483536e
commit bb7bceaa24
2 changed files with 33 additions and 7 deletions
+4
View File
@@ -44,6 +44,10 @@ type IdentityProviderDetails struct {
// 该认证源关联的所有域的组数量
GroupCount int `json:"group_count,allowempty"`
// 该认证源的URL, 可以区分ladp是否使用TLS
// example: ldaps://192.168.100.10, ldap://192.168.100.10
URL string `json:"url,allowempty"`
SIdentityProvider
}
+29 -7
View File
@@ -583,11 +583,40 @@ func (manager *SIdentityProviderManager) FetchCustomizeColumns(
stdRows := manager.SEnabledStatusStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
domainRows := manager.SDomainizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
targetDomainIds := make([]string, len(objs))
idpIds := make([]string, len(objs))
for i := range rows {
rows[i].EnabledStatusStandaloneResourceDetails = stdRows[i]
rows[i].DomainizedResourceInfo = domainRows[i]
idp := objs[i].(*SIdentityProvider)
rows[i].SyncIntervalSeconds = idp.getSyncIntervalSeconds()
targetDomainIds[i] = idp.TargetDomainId
idpIds[i] = idp.Id
rows[i] = objs[i].(*SIdentityProvider).getMoreDetails(rows[i])
}
domainMap, err := db.FetchIdNameMap2(DomainManager, targetDomainIds)
if err != nil {
log.Errorf("FetchIdNameMap2 error: %s", err)
}
opts := []struct {
DomainId string
Value string
}{}
err = WhitelistedConfigManager.Query("domain_id", "value").In("domain_id", idpIds).Equals("option", "url").All(&opts)
if err != nil {
log.Errorf("FetchModelObjects error: %s", err)
}
optMap := make(map[string]string)
for i := range opts {
optMap[opts[i].DomainId] = strings.Trim(opts[i].Value, `"`)
}
for i := range rows {
rows[i].TargetDomain = domainMap[targetDomainIds[i]]
rows[i].URL = optMap[idpIds[i]]
}
return rows
}
@@ -599,13 +628,6 @@ func (self *SIdentityProvider) getMoreDetails(out api.IdentityProviderDetails) a
out.DomainCount, _ = self.GetDomainCount()
out.ProjectCount, _ = self.GetProjectCount()
out.GroupCount, _ = self.GetGroupCount()
out.SyncIntervalSeconds = self.getSyncIntervalSeconds()
if len(self.TargetDomainId) > 0 {
domain, _ := DomainManager.FetchDomainById(self.TargetDomainId)
if domain != nil {
out.TargetDomain = domain.Name
}
}
return out
}