Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to new API #24

Open
nikzen opened this issue Aug 9, 2024 · 1 comment
Open

Switch to new API #24

nikzen opened this issue Aug 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@nikzen
Copy link

nikzen commented Aug 9, 2024

Description

There is a new API -> https://zitadel.com/docs/apis/resources/user_service_v2/user-service-add-human-user. This API would allow us to combine the create user & add metadata into one api call. It would also remove the nickname workaround, as we will be able to generate our own userId.

userId

  • With the old API, the Zitadel userId was generated by Zitadel.
  • With the new API, we are able to set our own userID.
  • We need to find a rule of how to generate this userId.
  • Suggestion: uuidv5-famedly-namespace (organizationId:idpId:user_id)

An example API call might look like this:

CURL
curl -L 'https://$CUSTOM-DOMAIN/v2/users/human' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
  "userId": "generatedUserId",
  "username": "email",
  "profile": {
    "givenName": "first_name",
    "familyName": "last_name",
    "displayName": "first_name, last_name"
  },
  "email": {
    "email": "email",
    "isVerified": true
  },
  "phone": {
    "phone": "phone",
    "isVerified": true
  },
  "metadata": [
    {
      "key": "localpart",
      "value": "uuidv5(user_id)"
    }
  ],
  "idpLinks": [
    {
      "idpId": "idpId",
      "userId": "user_id",
      "userName": "preferred_username"
    }
  ]
}

Deactivate / delete

Currently, we are using the nickname to search for users so that we can figure out the generated userId and then delete the user. We can remove the search API call, and directly delete all users based on the userId, as we know how the userId looks like. However, if we are in the deactivate-only mode we do not know the userid and have to search for the users, based on the mail address.

@nikzen nikzen added the enhancement New feature or request label Aug 9, 2024
@emgrav
Copy link
Member

emgrav commented Aug 15, 2024

Looks like the Zitadel crate already has support for v2 APIs in versions >=4.0.0:

https://github.com/smartive/zitadel-rust/releases/tag/v4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants