mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +00:00
feat: patch user scim v2 endpoint (#9219)
# Which Problems Are Solved * Adds support for the patch user SCIM v2 endpoint # How the Problems Are Solved * Adds support for the patch user SCIM v2 endpoint under `PATCH /scim/v2/{orgID}/Users/{id}` # Additional Context Part of #8140
This commit is contained in:
@@ -3,6 +3,8 @@ package metadata
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
)
|
||||
|
||||
type Key string
|
||||
@@ -30,21 +32,40 @@ const (
|
||||
KeyRoles Key = KeyPrefix + "roles"
|
||||
)
|
||||
|
||||
var ScimUserRelevantMetadataKeys = []Key{
|
||||
KeyExternalId,
|
||||
KeyMiddleName,
|
||||
KeyHonorificPrefix,
|
||||
KeyHonorificSuffix,
|
||||
KeyProfileUrl,
|
||||
KeyTitle,
|
||||
KeyLocale,
|
||||
KeyTimezone,
|
||||
KeyIms,
|
||||
KeyPhotos,
|
||||
KeyAddresses,
|
||||
KeyEntitlements,
|
||||
KeyRoles,
|
||||
}
|
||||
var (
|
||||
ScimUserRelevantMetadataKeys = []Key{
|
||||
KeyExternalId,
|
||||
KeyMiddleName,
|
||||
KeyHonorificPrefix,
|
||||
KeyHonorificSuffix,
|
||||
KeyProfileUrl,
|
||||
KeyTitle,
|
||||
KeyLocale,
|
||||
KeyTimezone,
|
||||
KeyIms,
|
||||
KeyPhotos,
|
||||
KeyAddresses,
|
||||
KeyEntitlements,
|
||||
KeyRoles,
|
||||
}
|
||||
|
||||
AttributePathToMetadataKeys = map[string][]Key{
|
||||
"externalid": {KeyExternalId},
|
||||
"name": {KeyMiddleName, KeyHonorificPrefix, KeyHonorificSuffix},
|
||||
"name.middlename": {KeyMiddleName},
|
||||
"name.honorificprefix": {KeyHonorificPrefix},
|
||||
"name.honorificsuffix": {KeyHonorificSuffix},
|
||||
"profileurl": {KeyProfileUrl},
|
||||
"title": {KeyTitle},
|
||||
"locale": {KeyLocale},
|
||||
"timezone": {KeyTimezone},
|
||||
"ims": {KeyIms},
|
||||
"photos": {KeyPhotos},
|
||||
"addresses": {KeyAddresses},
|
||||
"entitlements": {KeyEntitlements},
|
||||
"roles": {KeyRoles},
|
||||
}
|
||||
)
|
||||
|
||||
func ScopeExternalIdKey(provisioningDomain string) ScopedKey {
|
||||
return ScopedKey(strings.Replace(keyScopedExternalIdTemplate, externalIdProvisioningDomainPlaceholder, provisioningDomain, 1))
|
||||
@@ -58,3 +79,21 @@ func ScopeKey(ctx context.Context, key Key) ScopedKey {
|
||||
|
||||
return ScopedKey(key)
|
||||
}
|
||||
|
||||
func MapToScopedKeyMap(md map[string][]byte) map[ScopedKey][]byte {
|
||||
result := make(map[ScopedKey][]byte, len(md))
|
||||
for k, v := range md {
|
||||
result[ScopedKey(k)] = v
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func MapListToScopedKeyMap(metadataList []*query.UserMetadata) map[ScopedKey][]byte {
|
||||
metadataMap := make(map[ScopedKey][]byte, len(metadataList))
|
||||
for _, entry := range metadataList {
|
||||
metadataMap[ScopedKey(entry.Key)] = entry.Value
|
||||
}
|
||||
|
||||
return metadataMap
|
||||
}
|
||||
|
Reference in New Issue
Block a user