mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:47:33 +00:00
feat: list users scim v2 endpoint (#9187)
# Which Problems Are Solved - Adds support for the list users SCIM v2 endpoint # How the Problems Are Solved - Adds support for the list users SCIM v2 endpoints under `GET /scim/v2/{orgID}/Users` and `POST /scim/v2/{orgID}/Users/.search` # Additional Changes - adds a new function `SearchUserMetadataForUsers` to the query layer to query a metadata keyset for given user ids - adds a new function `NewUserMetadataExistsQuery` to the query layer to query a given metadata key value pair exists - adds a new function `CountUsers` to the query layer to count users without reading any rows - handle `ErrorAlreadyExists` as scim errors `uniqueness` - adds `NumberLessOrEqual` and `NumberGreaterOrEqual` query comparison methods - adds `BytesQuery` with `BytesEquals` and `BytesNotEquals` query comparison methods # Additional Context Part of #8140 Supported fields for scim filters: * `meta.created` * `meta.lastModified` * `id` * `username` * `name.familyName` * `name.givenName` * `emails` and `emails.value` * `active` only eq and ne * `externalId` only eq and ne
This commit is contained in:
@@ -208,6 +208,20 @@ func (h *UsersHandler) mapChangeCommandToScimUser(ctx context.Context, user *Sci
|
||||
}
|
||||
}
|
||||
|
||||
func (h *UsersHandler) mapToScimUsers(ctx context.Context, users []*query.User, md map[string]map[metadata.ScopedKey][]byte) []*ScimUser {
|
||||
result := make([]*ScimUser, len(users))
|
||||
for i, user := range users {
|
||||
userMetadata, ok := md[user.ID]
|
||||
if !ok {
|
||||
userMetadata = make(map[metadata.ScopedKey][]byte)
|
||||
}
|
||||
|
||||
result[i] = h.mapToScimUser(ctx, user, userMetadata)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (h *UsersHandler) mapToScimUser(ctx context.Context, user *query.User, md map[metadata.ScopedKey][]byte) *ScimUser {
|
||||
scimUser := &ScimUser{
|
||||
Resource: h.buildResourceForQuery(ctx, user),
|
||||
@@ -364,3 +378,11 @@ func userGrantsToIDs(userGrants []*query.UserGrant) []string {
|
||||
}
|
||||
return converted
|
||||
}
|
||||
|
||||
func usersToIDs(users []*query.User) []string {
|
||||
ids := make([]string, len(users))
|
||||
for i, user := range users {
|
||||
ids[i] = user.ID
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
Reference in New Issue
Block a user