Let's say I have three types of users on a blogging app
To manage this system I want to have three main services:
Now what I am struggling with is ownership of a resource (and where ownership should be checked).
Without communicating with other services how would an authorization service determine if a user should be able to access something they own without knowing how to determine if a user owns a given resource.
I've come up with a few different solutions to this problem, although I'm not quite happy with any of them.
Looking for ideas on alternative methods or insight into what the best solution to this problem might be.
Usually access to resources is based on the ownership of the resources. For example, a resource that represents insurance quotes. To access an insurance quote, you must be the user who made the quote.
Our approach is to expose the /quotes resource over the gateway with the path:
GET /quotes/{quoteId}
but to have the quotes microservice introduce the user ID into the quotes resource path like:
GET /quotes/{userId}/{quoteId}
This allows the quotes microservice to search for the quote within the context of the user, and to return a 404 if this path is not valid.
In order to enable this architecture, the gateway needs to gather the claims for the caller based on the caller's bearer token, and inject the value of the userId claim into the downstream path. This is illustrated below:
This ownership-based approach to access can be extended to include other claims (such as administrative claims, etc) very easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With