mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 23:37:32 +00:00

<!-- Please inform yourself about the contribution guidelines on submitting a PR here: https://github.com/zitadel/zitadel/blob/main/CONTRIBUTING.md#submit-a-pull-request-pr. Take note of how PR/commit titles should be written and replace the template texts in the sections below. Don't remove any of the sections. It is important that the commit history clearly shows what is changed and why. Important: By submitting a contribution you agree to the terms from our Licensing Policy as described here: https://github.com/zitadel/zitadel/blob/main/LICENSING.md#community-contributions. --> # Which Problems Are Solved Okta sends a random password in the request to create a user during SCIM provisioning, irrespective of whether the `Sync Password` option is enabled or disabled on Okta, and this password does not comply with the default password complexity set in Zitadel. This PR adds a workaround to create users without issues in such cases. # How the Problems Are Solved - A new metadata configuration called `urn:zitadel:scim:ignorePasswordOnCreate` is added to the Machine User that is used for provisioning - During SCIM user creation requests, if the `urn:zitadel:scim:ignorePasswordOnCreate` is set to `true` in the Machine User's metadata, the password set in the create request is ignored # Additional Changes # Additional Context The random password is ignored (if set in the metadata) only during customer creation. This change does not affect SCIM password updates. - Closes #10009 --------- Co-authored-by: Marco A. <marco@zitadel.com>
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package metadata
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
const bulkIDPrefix = "bulkid:"
|
|
|
|
type scimContextKeyType struct{}
|
|
|
|
var scimContextKey scimContextKeyType
|
|
|
|
type ScimContextData struct {
|
|
ProvisioningDomain string
|
|
IgnorePasswordOnCreate bool
|
|
ExternalIDScopedMetadataKey ScopedKey
|
|
bulkIDMapping map[string]string
|
|
}
|
|
|
|
func NewScimContextData() ScimContextData {
|
|
return ScimContextData{
|
|
ExternalIDScopedMetadataKey: ScopedKey(KeyExternalId),
|
|
bulkIDMapping: make(map[string]string),
|
|
}
|
|
}
|
|
|
|
func SetScimContextData(ctx context.Context, data ScimContextData) context.Context {
|
|
return context.WithValue(ctx, scimContextKey, data)
|
|
}
|
|
|
|
func GetScimContextData(ctx context.Context) ScimContextData {
|
|
data, _ := ctx.Value(scimContextKey).(ScimContextData)
|
|
return data
|
|
}
|
|
|
|
func SetScimBulkIDMapping(ctx context.Context, bulkID, zitadelID string) context.Context {
|
|
data := GetScimContextData(ctx)
|
|
data.bulkIDMapping[bulkID] = zitadelID
|
|
return ctx
|
|
}
|
|
|
|
func ResolveScimBulkIDIfNeeded(ctx context.Context, resourceID string) (string, error) {
|
|
lowerResourceID := strings.ToLower(resourceID)
|
|
if !strings.HasPrefix(lowerResourceID, bulkIDPrefix) {
|
|
return resourceID, nil
|
|
}
|
|
|
|
bulkID := strings.TrimPrefix(lowerResourceID, bulkIDPrefix)
|
|
data := GetScimContextData(ctx)
|
|
zitadelID, ok := data.bulkIDMapping[bulkID]
|
|
if !ok {
|
|
return bulkID, zerrors.ThrowInvalidArgumentf(nil, "SCIM-BLK4", "Could not resolve bulkID %v to created ID", bulkID)
|
|
}
|
|
|
|
return zitadelID, nil
|
|
}
|