mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8906 from swordqiu/feature/qj-filter-domain-user-by-idp-entity-id
feat(keystone): filter domain/user by idp_entity_id
This commit is contained in:
@@ -25,7 +25,8 @@ import (
|
||||
func init() {
|
||||
type DomainListOptions struct {
|
||||
options.BaseListOptions
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
IdpEntityId string `help:"filter by idp_entity_id"`
|
||||
}
|
||||
R(&DomainListOptions{}, "domain-list", "List domains", func(s *mcclient.ClientSession, args *DomainListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
|
||||
@@ -31,6 +31,7 @@ func init() {
|
||||
OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
|
||||
Role string `help:"Filter by role"`
|
||||
IdpId string `help:"filter by idp_id"`
|
||||
IdpEntityId string `help:"filter by idp_entity_id"`
|
||||
}
|
||||
R(&UserListOptions{}, "user-list", "List users", func(s *mcclient.ClientSession, args *UserListOptions) error {
|
||||
params, err := options.ListStructToParams(args)
|
||||
|
||||
@@ -167,6 +167,9 @@ type DomainListInput struct {
|
||||
|
||||
// 按IDP过滤
|
||||
IdpId string `json:"idp_id"`
|
||||
|
||||
// 按IDP_ENTITY_ID过滤
|
||||
IdpEntityId string `json:"idp_entity_id"`
|
||||
}
|
||||
|
||||
type UserListInput struct {
|
||||
@@ -191,6 +194,9 @@ type UserListInput struct {
|
||||
|
||||
// 关联IDP
|
||||
IdpId string `json:"idp_id"`
|
||||
|
||||
// 按IDP_ENTITY_ID过滤
|
||||
IdpEntityId string `json:"idp_entity_id"`
|
||||
}
|
||||
|
||||
type EndpointListInput struct {
|
||||
|
||||
@@ -205,6 +205,11 @@ func (manager *SDomainManager) ListItemFilter(
|
||||
q = q.In("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
if len(query.IdpEntityId) > 0 {
|
||||
subq := IdmappingManager.Query("public_id").Equals("local_id", query.IdpEntityId).Equals("entity_type", api.IdMappingEntityDomain)
|
||||
q = q.Equals("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -400,6 +400,11 @@ func (manager *SUserManager) ListItemFilter(
|
||||
q = q.In("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
if len(query.IdpEntityId) > 0 {
|
||||
subq := IdmappingManager.Query("public_id").Equals("local_id", query.IdpEntityId).Equals("entity_type", api.IdMappingEntityUser)
|
||||
q = q.Equals("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user