-
Hi, I was planning to build a microservice architecture that include Flask microservices and a Nextjs frontend which will access them (Later there might be a mobile app). Everything should only be accessible when a user is logged in. In addition to that there should be roles like "user" or "admin" that will restrict specific routes to users that have them only. The frontend should have access to that roles too, and conditionally render components based on those roles. My current implementation in Keycloak is, that the frontend signs in, gets a JWT that includes the roles assigned to a user via Keycloak. This JWT gets checked via a middleware in the Flask services, and the roles are parsed and checked against the current route. The same is done in the frontend. The microservices itself have routes, on which they call each other, that should only be accessible from the microservices itself, not the logged in user Now to the Ory part. As I have seen in some examples, you can use Ory Kratos and Keto. When it comes to the auth and permission check in the Flask microservices, the /whoami route is used and with a direct call to keto you can check the permission. So Ory Oathkeeper would be an option too, which works as a reverse proxy before those services doing permissions for routes in its middleware. But with this approach, I can't do the conditional rendering in the Frontend. As you can see, I am a little bit confused what is the right setup/approach when using Ory for a microservice architecture. Greetings |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
hey @noctera Your use case is quite complex and involves several components of the Ory stack. Let's try to break it down:
That is true, but you also always get the latest data from the authentication/authorization(Kratos/Keto) server. So when the user logs out or a permission changes this is instantly reflected. It does depend on the use case what you want, did you have a specific case in mind where you wanted to use Ory? I hope this gives you a starting point for your implementation. |
Beta Was this translation helpful? Give feedback.
hey @noctera
Your use case is quite complex and involves several components of the Ory stack. Let's try to break it down: