diff --git a/cmd/climc/shell/identity/domains.go b/cmd/climc/shell/identity/domains.go index f74f57dfa9..e0cf0e0b7e 100644 --- a/cmd/climc/shell/identity/domains.go +++ b/cmd/climc/shell/identity/domains.go @@ -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) diff --git a/cmd/climc/shell/identity/users.go b/cmd/climc/shell/identity/users.go index 57dc462719..436eea5786 100644 --- a/cmd/climc/shell/identity/users.go +++ b/cmd/climc/shell/identity/users.go @@ -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) diff --git a/pkg/apis/identity/input.go b/pkg/apis/identity/input.go index 3fe9528091..e54f3a8b2b 100644 --- a/pkg/apis/identity/input.go +++ b/pkg/apis/identity/input.go @@ -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 { diff --git a/pkg/keystone/models/domains.go b/pkg/keystone/models/domains.go index 128ce5f3c1..57198da3c8 100644 --- a/pkg/keystone/models/domains.go +++ b/pkg/keystone/models/domains.go @@ -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 } diff --git a/pkg/keystone/models/users.go b/pkg/keystone/models/users.go index ead4eb60e9..9e2567ce31 100644 --- a/pkg/keystone/models/users.go +++ b/pkg/keystone/models/users.go @@ -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 }