Retrieving user information in a proxied microservice #503
-
Probably due to my lack of knowledge (I’m fairly new to both Identity management and proxying), but I have trouble understanding how I can achieve functionality like this:
How can I get to the information of the logged on users (name, claims etc)? Do I need custom written middleware in the proxy? Or can I just put some "existing" middleware in the microservice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
So if I understand this right, you have auth set up in destination A as shown above, and you want to share that user information with the app at destination B? There's no auth set up in the proxy? That user information is preserved in the auth cookie which is attached to each request. All the microservice needs to do is read that cookie. The easiest way to do that is to add cookie auth to the microservice. There are two steps:
Since cookie auth set set as the default in that example, the app will automatically read the cookie on each request and set HttpContext.User. |
Beta Was this translation helpful? Give feedback.
So if I understand this right, you have auth set up in destination A as shown above, and you want to share that user information with the app at destination B? There's no auth set up in the proxy?
That user information is preserved in the auth cookie which is attached to each request. All the microservice needs to do is read that cookie. The easiest way to do that is to add cookie auth to the microservice. There are two steps:
The apps need to share encryption keys so they can both read the cookies. That's configured through DataProtection:
https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-3.1
Add cookie auth to the microservice: