Replies: 4 comments 4 replies
-
Thank you for this detailed explanation. I think that you can go with the two-variant version of Ory Kratos, or potentially also introduce a second identity schema for machine users and only create them via the Admin API. Another alternative is to use the OAuth2 Client Credentials grant which is basically what a service account could do. It doesn't require user interaction and works with a variety of authentication mechanisms, including mTLS at some point. This might come in handy when we're talking Istio! You might also be able to leverage RFC7523 ( https://www.ory.sh/docs/hydra/guides/oauth2-grant-type-jwt-bearer ) to generate tokens on behalf of someone without user interaction. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the input @aeneasr! A second identity schema! 💡 This managed to sneak past us while coming up with solutions, even after recently migrating to 0.9.0 and changed our configs to We have looked further into Client Credentials since and believe this definitely could work. I personally need to brush up on the concept and understand what entities are provided once a successful request is made, and how they can fit into our current middleware (i.e. Keto checks for specific resources are currently tied to identity IDs) or if we would need another piece of middleware. I wouldn't be able to make that decision until I do some more research. As for RFC7523, I think our problem lies in having an organisation layer, where we ideally don't want a single (real) user to be responsible for access to the FaaS APIs hosted by the organisation. Our fear is that a user may leave an organisation, rendering the JWT as unusable; breaking all clients in the process. Again, this may be something we either need to do more research on, or need to mitigate. We discussed implementing a process that swaps a user's responsibilities/permissions to the organisation owner when they leave/are removed, but again we aren't sure if this is possible with JWTs without testing. Thanks again, we really appreciate you taking the time to input on this! |
Beta Was this translation helpful? Give feedback.
-
I just replied to someone on Slack asking about api keys, but thought it would be nice to have here for searchability Copied from SlackA few solutions include:
There is also a blog post that touches on how you can use Kong’s api key plugin paired with Oathkeeper and Kratos to add api keys to your auth stack https://www.ory.sh/zero-trust-api-security-ory-tutorial/ A similar configuration to the reverse proxy stuff can be seen in this Ory Summit video too! https://www.youtube.com/watch?v=A_IH_1NW7cM&t=245s Also worth noting that we use gRPC/gRPC-Web, which I believe isn’t supported by Oathkeeper, so this made things a little more complicated for us! |
Beta Was this translation helpful? Give feedback.
-
This may be relevant for this topic: |
Beta Was this translation helpful? Give feedback.
-
Hello, I would love to open a discussion about the use of Ory Kratos for service accounts, for use in service-to-service authentication/authorisation where a user would normally be present.
Setup
Currently, we are using middleware for our IAM solution; one that makes a request to Kratos’
session/whoami
endpoint for a user session based on theory_kratos_session
cookie sent from the frontend - this session is then injected into the request flow’s context - and another that performs various Keto Check requests using the injected user session. Once a request makes it past the middleware, we run the request in the context of that user.Problem
Our problem arose when we began exposing the functionality of our services as user-definable HTTP APIs, where a user is no longer involved in the process. For reference, we are building a no-code tool that allows organisations to build functions-as-a-service.
Our
endpoint service
is responsible for taking the requests to these user-defined endpoints and executing them. In order to do this, we must contact a few services to prepare the request, and finally make a request to theexecution service
to execute the request. As these requests are made without the context of a user, we hit the (purposely erected) wall of our middleware.Solutions
A good few hours of discussion later and we came up with a few possible solutions.
(e.g.
ory_session_cookie: localhost:4466
andory_service_cookie: localhost:4499
) and have the service that needs to make these requests use theory_service_cookie
in its requests to other services.Diagrams
I pulled together some diagrams for our current request flow and our proposed “Kratos 2” flow (as we’re calling it internally).
Kratos 1 - User Accounts
Kratos 2 - Service Accounts
Issues/Concerns
At the moment, it appears that Kratos doesn’t clear any of its flow or session data once expired. As a service account could potentially be logged in many times in a short period (maybe even concurrently), these tables begin to fill with a lot of redundant data. I believe there have been PRs/issues open for these redundant entries, and I believe a clean up tool is due to be released in the future.
Without testing, we are unsure if Kratos is even suitable for this level of traffic with constant login flows being generated, and whether concurrent/multiple sessions are even possible.
We would also like to have the TTL of these sessions be around the same time as our execution timeout, so very short. Again, without testing we’re unsure of the minimum expiry time of a session.
Conclusion
We are essentially looking to build something similar to AWS’ IAM page, where you can create users that represent either a person (regular users) or a service (service users). In our setup, this would not be a single account that the service logs into, but instead one that the “API logs into” using the credentials provided in the HTTP request. We want to enable our customers to generate and manage API tokens which can be authorise to use our backend on an organisation’s behalf.
We think we’re trying to tackling something here that others may find useful. Any input is massively appreciated!
Beta Was this translation helpful? Give feedback.
All reactions