Hey peeps, is there any sample repo, boilerplate c...
# ory-network
c
Hey peeps, is there any sample repo, boilerplate code, or whatever I could copy to implement the Ory Elements inside? We want more control over the GUI and avoid the hosted self-managed version.
m
Hey Yordis, Does https://github.com/ory/elements/tree/main/examples help? AFAIK https://github.com/ory/kratos-selfservice-ui-node/ (that is the hosted console UI) also uses ory/elements
c
Does examples help a ton!
I am trying to avoid the Keycloak problems of using hosted console UI, we need some hidden fields (affiliate code that will be an admin metadata copied form the query params) and whatnot, and I am fearful to end up doing the work of using my own UI anyway
any thoughts?
Am I able to use the self-service and/or call directly the Ory API if I need to enforce admin metadata? I feel I should disable the registration form and only use the admin manually for registering. I am not sure!
Ideally we dont care using the self-serving GUI from the ory-network but as long as we can inject few parameters that come from the query params, and cookies as part of the admin metadata
Maybe I could leverage the
transient_payload
? Intent: upon registration save an affiliate code associated to the user, but the user can not change that later
Which same situation using Social Sign-in, I need to save that tricky affiliate code 😞
s
You can store the code in the
metadata_admin
or
metadata_public
https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata#metadata using a webhook after registration: https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks Note that you have to use the admin API including an API key to update any of the metadata fields.
For UI, if the hosted solution is not sufficient, we recommend to build your own using Ory Elements. They help a lot, but are just a library so you can still do all kinds of funky stuff around it. Going completely custom is obviously also possible but more work for you.
c
@steep-lamp-91158 I am aware of the
metadata
stuff, just that I need to figure out how to implement the registration workflow and things like that!
I ended up building everything from scratch in Elixir waiting for your response just in case. I prefer if I can find whatever endpoints I need to implement everything
But I am not sure what endpoints would be a replacement for the self-serving. Do you have the list of APIs I should use (and maybe the order) to replace the self-serving registration* and keep the other things maybe?
s
I am not sure I can follow... do you want to disable registration?
c
ideally, no, no really. All I need is to be able to add extra
admin metadata
upon registration. So as long as I can do that, i am good with it
In the worst case, should I disable the Registration? If so, then what needs to be involved to custom build my registration and be able to create the identity, and the session and the stuffs that needs to happen for the "normal" registration flow?
s
As posted above, you can do anything in the after registration webhook, like e.g. adding metadata through the admin API
c
That would require me to write things into cookies to then pick the information up
Is that what you are recommending to do?
Because that is what I am trying to avoid
Ideally the registration endpoint is used in my backend (so I can add the extra admin metadata) but the rest is almost the same, like a tiny proxy
m
I don’t know if that (writing things into cookies) was the intention, but I think not. You can run the webhook after registration to add metadata:
When the webhook target returns a 200 OK response code and the response body is a JSON object with the key
identity.metadata_public
or
identity.metadata_admin
in it, the values from that object will be used to replace the identity metadata fields before they are saved to the database.
https://www.ory.sh/docs/guides/integrate-with-ory-cloud-through-webhooks#update-identity-metadata
c
How? I know you keep saying the same, so am I, so let me try to change what I am saying
How could the webhook has access to an information that is only present in the URL as a query param of the user browser without me pausing that information somehow?
Are the webhook custom JS code that runs in the webpage? Maybe that is where I am missing something
Webhook could work if I have that information in my system already and can correlate to the user somehow.
Reasons why I am saying that what I am asking to some extent is to be able to register with some metadata the user could enter. Otherwise, I have to move that information into the traits itself but the tricky bit is that we do not want to allow the users to change anything after
Which, I guess I could copy the info from the traits into the metadata using the webhook and remove the trait … but that sounds odd, especially that we have many metadata to deal with, and sometimes they come and go also
I guess I was left alone 😞
s
See the transient payload on web hooks. You could also submit the other data to a custom API before submitting the registration. I would not allow users/frontend to control stuff you put in the metadata in the first place, so if possible I would generate the value on the back end.
Oh and sorry that we have to sleep some time, but this is a community slack, not a 24/7 support hotline. Just to manage expectations here.
c
I see. The transient payload + hooks are how you want people to think about it. Thank you so much!
I didn’t realize you were in a different time zone. My apologies. I am not expecting you to be a 24/7 support hotline at all, just wanted to get it done to move our customers to Ory Network so I can focus on the actual work. Thank you for your help, appreciated!