mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-17 10:55:12 +00:00
feat: create user scim v2 endpoint (#9132)
# Which Problems Are Solved
- Adds infrastructure code (basic implementation, error handling,
middlewares, ...) to implement the SCIM v2 interface
- Adds support for the user create SCIM v2 endpoint
# How the Problems Are Solved
- Adds support for the user create SCIM v2 endpoint under `POST
/scim/v2/{orgID}/Users`
# Additional Context
Part of #8140
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type provisioningDomainKeyType struct{}
|
||||
|
||||
var provisioningDomainKey provisioningDomainKeyType
|
||||
|
||||
type ScimContextData struct {
|
||||
ProvisioningDomain string
|
||||
ExternalIDScopedMetadataKey ScopedKey
|
||||
}
|
||||
|
||||
func SetScimContextData(ctx context.Context, data ScimContextData) context.Context {
|
||||
return context.WithValue(ctx, provisioningDomainKey, data)
|
||||
}
|
||||
|
||||
func GetScimContextData(ctx context.Context) ScimContextData {
|
||||
data, _ := ctx.Value(provisioningDomainKey).(ScimContextData)
|
||||
return data
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Key string
|
||||
type ScopedKey string
|
||||
|
||||
const (
|
||||
externalIdProvisioningDomainPlaceholder = "{provisioningDomain}"
|
||||
|
||||
KeyPrefix = "urn:zitadel:scim:"
|
||||
KeyProvisioningDomain Key = KeyPrefix + "provisioning_domain"
|
||||
|
||||
KeyExternalId Key = KeyPrefix + "externalId"
|
||||
keyScopedExternalIdTemplate = KeyPrefix + externalIdProvisioningDomainPlaceholder + ":externalId"
|
||||
KeyMiddleName Key = KeyPrefix + "name.middleName"
|
||||
KeyHonorificPrefix Key = KeyPrefix + "name.honorificPrefix"
|
||||
KeyHonorificSuffix Key = KeyPrefix + "name.honorificSuffix"
|
||||
KeyProfileUrl Key = KeyPrefix + "profileURL"
|
||||
KeyTitle Key = KeyPrefix + "title"
|
||||
KeyLocale Key = KeyPrefix + "locale"
|
||||
KeyTimezone Key = KeyPrefix + "timezone"
|
||||
KeyIms Key = KeyPrefix + "ims"
|
||||
KeyPhotos Key = KeyPrefix + "photos"
|
||||
KeyAddresses Key = KeyPrefix + "addresses"
|
||||
KeyEntitlements Key = KeyPrefix + "entitlements"
|
||||
KeyRoles Key = KeyPrefix + "roles"
|
||||
)
|
||||
|
||||
var ScimUserRelevantMetadataKeys = []Key{
|
||||
KeyExternalId,
|
||||
KeyMiddleName,
|
||||
KeyHonorificPrefix,
|
||||
KeyHonorificSuffix,
|
||||
KeyProfileUrl,
|
||||
KeyTitle,
|
||||
KeyLocale,
|
||||
KeyTimezone,
|
||||
KeyIms,
|
||||
KeyPhotos,
|
||||
KeyAddresses,
|
||||
KeyEntitlements,
|
||||
KeyRoles,
|
||||
}
|
||||
|
||||
func ScopeExternalIdKey(provisioningDomain string) ScopedKey {
|
||||
return ScopedKey(strings.Replace(keyScopedExternalIdTemplate, externalIdProvisioningDomainPlaceholder, provisioningDomain, 1))
|
||||
}
|
||||
|
||||
func ScopeKey(ctx context.Context, key Key) ScopedKey {
|
||||
// only the externalID is scoped
|
||||
if key == KeyExternalId {
|
||||
return GetScimContextData(ctx).ExternalIDScopedMetadataKey
|
||||
}
|
||||
|
||||
return ScopedKey(key)
|
||||
}
|
||||
Reference in New Issue
Block a user