Hello! I have a use case where I’d like to retrie...
# ory-network
f
Hello! I have a use case where I’d like to retrieve a subset of users. So far I’ve found https://www.ory.sh/docs/kratos/reference/api#tag/identity/operation/listIdentities where I can either retrieve all users or an individual based on email. Preferably I’d like to be able to call the API with a set of ory identity ids.
Copy code
/admin/identities?id=0bf938ff-a742-4db0-92ed-53bcb9efdd1,0bf938ff-a742-4db0-92ed-53bcb9efdd2,0bf938ff-a742-4db0-92ed-53bcb9efdd3,0bf938ff-a742-4db0-92ed-53bcb9efdd4
for example. Is this possible?
More background is that so far I’ve tried avoid storing the data in our internal db that we have only in Ory (username, email) for GDPR reasons as well as not duplicating data with the risk of the data getting out of sync. I would prefer doing that but if I can only retrieve users with individual requests I will have to reconsider.
Storing traits in our own database feels like an anti-pattern since the user can update themselves fully through frontend.
@proud-plumber-24205 Perhaps?
p
Hi @fast-eve-41839 We don't have an API described above. What is your use case?
f
In my application I’d like to list a subset of users (50 or so) that the frontend is interested in. The frontend is interested in seeing email/display name. My application itself does not store the email address, that is something I only want to keep in Ory for GDPR and deduplication reasons. The flow is therefore 1. Frontend calls my backend for retrieving a subset of users 2. My backend retrieves the subset of users in question (these users have an ory identity id that I store in the db) 3. Based on the list of ory identity ids that I have I’d like to call Ory preferably one time to get all of the corresponding users. 4. Compile the internal database representation from 2 and 3 and respond to the frontend.
Currently since 3. isn’t available I have two choices a) Duplicate the data that I store in Ory. This is a bad idea imo since then I have to make sure the data (email/display name) between Ory and my backend application are in sync. A user could change the email without the backend knowing for example which I think is an expected flow (since the backend should not care). b) Call Ory for each individual identity id meaning if I have 50 users I’ll be making 50 calls to Ory, not a very scalable approach.
p
hmm, so in your case, you already have the identity ids and care about retrieving those specific identities. Unfortunately we don't have a clean solution to this problem at the moment. I'll create an issue for this so we can track it. As a workaround, maybe you could poll Ory every couple of hours for the list of identities and store them in-memory for your frontend to consume. So instead of chaining the request from your frotnend -> backend -> Ory, you instead have a background task retrieving data from Ory every X hours and then your frontend only calls your backend. The data will be a bit behind, but will eventually be consistent. Another option is to have a webhook call your backend with the created identity on registration and then on settings update again with the updated info. In this case you duplicate the data and keep it in-sync using webhooks.
f
Thanks! The webhook alternative seems like something that could work even though I’d prefer not to store duplicated/gdpr data for now.
p
I have created an issue here for your reference https://github.com/ory/network/issues/305
f
Thank you very much!