Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing Ocelot to Automatically Forward Claims from IdentityServer's Introspection Endpoint to Backend Services #2024

Closed
niyozbekmirzayev opened this issue Mar 30, 2024 · 1 comment
Labels
Authentication Ocelot feature: Authentication Authorization Ocelot feature: Authorization waiting Waiting for answer to question or feedback from issue raiser

Comments

@niyozbekmirzayev
Copy link

We expect Ocelot to forward the claims obtained from IdentityServer4's introspection endpoint to the backend services, enabling efficient authentication and authorization within our microservice architecture.

Currently, Ocelot does not forward the claims retrieved from the introspection endpoint to the backend services. This leads to inefficiencies, as each microservice must independently query IdentityServer4 for claims, resulting in unnecessary round trips.

To optimize our authentication and authorization process, we aim to enhance Ocelot's functionality. Specifically, we seek a feature that automatically passes the obtained claims from the introspection endpoint to the backend services, reducing reliance on IdentityServer and minimizing round trips.

Configure Ocelot as the API Gateway in a microservice architecture.
Integrate IdentityServer4 for authentication and authorization.
Ensure each microservice sends requests to IdentityServer4's introspection endpoint to retrieve claims.
Observe that Ocelot does not forward the obtained claims to the backend services.

Version: Ocelot 18.0
Platform: .NET 6
Subsystem: Authentication and Authorization

@raman-m
Copy link
Member

raman-m commented Apr 1, 2024

I don't get you!


We expect Ocelot to forward the claims obtained from IdentityServer4's introspection endpoint to the backend services, enabling efficient authentication and authorization within our microservice architecture.

To forward the claims means to forward auth token. Just define anonymous route to forward your token down to the service. Authorization will occur on the side of the downstream service.


Currently, Ocelot does not forward the claims retrieved from the introspection endpoint to the backend services. This leads to inefficiencies, as each microservice must independently query IdentityServer4 for claims, resulting in unnecessary round trips.

resulting in unnecessary round trips.

Hmm... What's the problem with that?
You only have to create the token once before sending a request to gateway! Attach it to request, make request to upstream and anonymous route will forward it to the service which require authorization.


To optimize our authentication and authorization process, we aim to enhance Ocelot's functionality.

Great! Sure thing you can do that!


Specifically, we seek a feature that automatically passes the obtained claims from the introspection endpoint to the backend services, reducing reliance on IdentityServer and minimizing round trips.

But I've explained you above how. Make token once, and reuse it for all Ocelot's routes. But they should be anonymous! So, authorization will take place on microservice's side.
There will be no "round trips"! 😉


Configure Ocelot as the API Gateway in a microservice architecture.
Integrate IdentityServer4 for authentication and authorization.
Ensure each microservice sends requests to IdentityServer4's introspection endpoint to retrieve claims.
Observe that Ocelot does not forward the obtained claims to the backend services.

Awesome Steps to Reproduce! 🤣
If you want to check claims on Ocelot's side and want to have some claims transformations then you have to develop custom Authentication middleware and attach it to the pipeline using Middleware Injection
Probably your user's scenario requires to override AuthorizationMiddleware too.

Hope it helps!

Version: Ocelot 18.0
Platform: .NET 6
Subsystem: Authentication and Authorization

Why do you use outdated version?
Please upgrade to version 23.1+!

@raman-m raman-m added waiting Waiting for answer to question or feedback from issue raiser Authentication Ocelot feature: Authentication Authorization Ocelot feature: Authorization labels Apr 1, 2024
@ThreeMammals ThreeMammals locked and limited conversation to collaborators Apr 11, 2024
@raman-m raman-m converted this issue into discussion #2043 Apr 11, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Authentication Ocelot feature: Authentication Authorization Ocelot feature: Authorization waiting Waiting for answer to question or feedback from issue raiser
Projects
None yet
Development

No branches or pull requests

2 participants