How does Ory Kratos handle user groups? For exampl...
# talk-kratos
t
How does Ory Kratos handle user groups? For example, I have a group for employees and another for customers but using the same Ory Kratos?
f
Hi, it could be that the separate identities schemas may help -
Copy code
## Additional JSON Schemas for Identity Traits ##
  # schemas:
  #   - id: customer
  #   url: <https://foo.bar.com/path/to/customer.traits.schema.json>
  # - id: employee
  #   url: <https://foo.bar.com/path/to/employee.traits.schema.json>
if you need an authorization layer - then you can check the ory kratos
t
Hi @faint-insurance-61054, thanks. I did implement the identity traits. I have a default which is for everyone and another for employee which only has the employee id for now. I'm hoping that the employee schema will have all the properties of the default schema and then with the employee id.
Basically,
Copy code
User Schema: username, password, email, phone
Employee Schema: employee_id
When logging in as an employee, I want the employee_id to be returned as well.
f
what about to store the employee id in the metadata_admin ?
t
Haven't tried that yet. What's metadata used for?
f
you can store on identity level some custom information
metadata_admin fits well for storing user role, etc ..
it can’t be modified by user
t
I just saw it. This is exactly what I need. Thank you
f
you are welcome 🙂
t
Hmmm I cannot find an example schema that uses metadata. Do you have one by any chance?
f
it is not part of the schema
you need to add that filed via admin api
employee is registering -> server sends additional call to kratos admin api and adds employee fields for metadata_admin
t
I see.
f
you can try even to use hooks
• let’s say
after
registration: The hook runs when a user successfully registers in the system.
t
Copy code
"metadata_public": null,
        "metadata_admin": null,
f
Copy code
yep
t
so i don't even need a schema for employees then. I just have to set the employee id if they are employee
f
yes
t
thank you. i understand it now
f
good luck with integration 🙂
t
Another question if you don't mind. How does ory hydra determine metadata stuff from kratos?