acoustic-shampoo-32095
11/22/2023, 8:37 AMauthorizers:
allow:
enabled: true
remote_json:
enabled: true
config:
remote: <http://keto:4466/relation-tuples/check|http://keto:4466/relation-tuples/check>
payload: |
{
"namespace": "api_access",
"object": "endpoints",
"relation": "access",
"subject_id": "{{ print .Extra.identity.metadata_admin.role }}"
}
acoustic-shampoo-32095
11/22/2023, 1:49 PMacoustic-shampoo-32095
11/23/2023, 8:58 AMacoustic-shampoo-32095
11/23/2023, 2:42 PMacoustic-shampoo-32095
11/24/2023, 2:06 PMacoustic-shampoo-32095
11/25/2023, 12:34 AMfancy-wall-65751
11/25/2023, 12:16 PMadmin/identies/{id}
directly. But I guess that implies some redirection (resolving session, then getting the user’s roles).
https://www.ory.sh/docs/kratos/manage-identities/managing-users-identities-metadata#metadata
I noticed you mentioned a tenant id you’d want to retrieve, however there’s this note on multitenancy: https://www.ory.sh/docs/kratos/guides/multi-tenancy-multitenant
-----fancy-wall-65751
11/25/2023, 12:23 PMrole:pet_shop_employee#members@(User:Julius)
role:admin#members@(User:Empty)
api_access:get_pets#members@(role:pet_shop_employee)
api_access:get_pets#members@(role:admin)
acoustic-shampoo-32095
11/25/2023, 12:29 PMfancy-wall-65751
11/25/2023, 1:01 PMSo I solved it by creating the tenantId for each identity and passing it upstream with the id_token mutator. It works fine. So I have just one database with all the users but each user may or may not in another tenant.Interesting choice to link identities to a specific tenant. This implies that an identity can never be part of multiple tenants. I think can be especially difficult when dealing with OPS/admin accounts
Requesting metadata_admin information from admin/identies/{id} works but I would need to create a custom authorizer or authenticator I think. I was looking for a way where oathkeeter can manage this on its own like when using the whoamI endpoint without me creating custom code.
I am currently using the metadata_public and it works, but I do not know if it is secure enough since it can be seen. not edited though.The less information you can expose to a user, the better. Unless there is a good use case for users to know / see their roles, I’d leave it out as much as possible. A tenantId might be somewhat harmless, but roles are a bit more tricky. I’m interested in Ory’s take on this as well.
I do not know how to do the zanzibar style without to much overhead. creating the tuples for the roles and the access rules for oathkeeper is already painful enough.I’m gonna take a guess and state that you have a mechanism to initially set the metadata of the user that happens during registration, and maybe you have a sync mechanism as well, to make sure changes to any user’s roles are reflected. Alternatively, in kratos, the source of truth is maintained, and you have an admin flow to mutate a user’s roles. Rather than saving this information in the user’s metadata, you cold opt for syncing this with Keto directly, which is only a matter of changing the api call to kratos to keto iiuc.
acoustic-shampoo-32095
11/25/2023, 4:07 PMInteresting choice to link identities to a specific tenant. This implies that an identity can never be part of multiple tenants. I think can be especially difficult when dealing with OPS/admin accountsThats what I am aiming for as of now. Maybe I will think about another approach where the user may be added to multiple tenants. But it is no prio for me.
I’m gonna take a guess and state that you have a mechanism to initially set the metadata of the user that happens during registration, and maybe you have a sync mechanism as well, to make sure changes to any user’s roles are reflected. Alternatively, in kratos, the source of truth is maintained, and you have an admin flow to mutate a user’s roles. Rather than saving this information in the user’s metadata, you cold opt for syncing this with Keto directly, which is only a matter of changing the api call to kratos to keto iiuc.Yep, I have my own user database where I add the roles based on registration and user information update e.g. changing roles etc. these changes are also applied to the kratos identity which is then used to access api endpoints. When oathkeeper evaluates the requests it checks the role of the user. this role is then passed to keto to check if the requested api can be accessed with the role information of the user. In addition to this I send the tenantId, the role and the userId in an id_token upstream to the service where a middleware decodes these claims and adds them into the context. the handler then passed theses values to the service.
fancy-wall-65751
11/25/2023, 4:26 PMacoustic-shampoo-32095
12/09/2023, 12:10 PM