adobe-apiplatform / umapi-client.py

Python client for the User Management API (UMAPI) from Adobe
https://developer.adobe.com/umapi/
MIT License
12 stars 19 forks source link

Erroneous client-side validation prevents renaming Federated ID users #106

Closed s3lph closed 1 year ago

s3lph commented 1 year ago

Description

We're using umapi_client to sync local users to UMAPI federatedID users. One use case in this sync is renaming users.

When renaming a user, we want to change both the username and the email of the federatedID user, which umapi_client forbids.

Actual Behavior

user_action.update(email=lu.email, username=lu.email)
con.execute_single(user_action)

However, this fails due to this check in UserAction.update:

https://github.com/adobe-apiplatform/umapi-client.py/blob/74e8c1e13e45070e112c88804a8057af639f57dd/umapi_client/functional.py#L180-L181

So we tried to follow the instructions in this error message (it claims that when chaning the email, the username will be changed as well):

user_action.update(email=lu.email)
con.execute_single(user_action)

However, the username is in fact not updated. Effectively, this prevents the affected user from logging in:

Trying to set the username separately from the email fails due to another check in UserAction.update:

https://github.com/adobe-apiplatform/umapi-client.py/blob/74e8c1e13e45070e112c88804a8057af639f57dd/umapi_client/functional.py#L178-L179

So we tried to circumvent this check:

user_action.update(email=local_user.email)
user_action.commands[-1]['update']['username'] = local_user.email
con.execute_single(user_action)

And see there, it works: Both the username and the email are updated, and the user can log in again.

Expected Behavior

Renaming a federatedID user should work without having to circumvent erroneous client-side checks:

Environment

adorton-adobe commented 1 year ago

I'll take a look. While I do that will you please test this in v2.20 which is the latest version? Not sure it will resolve the issue but it may.