We are working on a system where we have YARP as a gateway and several APIs for different data domains. The APIs are protected with Azure AD. Using MSAL (Microsoft.Identity.Web) is easy as there are many examples of how to protect APIs or Web Apps. The APIs are called from different types of clients (SPA, CLI apps, web apps, etc...), and with different flows. Now, one of the requirements is that YARP works as a first line of defense, and for this we want YARP to validate the JWTs that are sent through each of the protected routes, that is, we want to authenticate and authorize each call. Although the authority (IdP) for all the APIs is the same, Azure AD, not all of them are registered in the same tenant and of course, the client-Id (audience) is different for each API. Has anyone had to implement something similar? Note: We don't want to validate specific scopes per route and in terms of authorization it is enough to validate that the user is authenticated.
How to validate the audience in the YARP routes?
326 views Asked by EmilioV At
1
There are 1 answers
Related Questions in AZURE-ACTIVE-DIRECTORY
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in AZURE-AD-MSAL
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in MICROSOFT-IDENTITY-WEB
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in MS-YARP
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The scenario you're describing – where a reverse proxy or gateway is responsible for validating JWT tokens before forwarding requests to various microservices or APIs – is not uncommon. YARP is designed to be highly customizable, and with .NET's middleware pipeline, you can integrate JWT validation.
I am describing below an approach we had used in one of the projects.
1. Set Up Azure AD with Multiple Apps
We had multiple Azure AD Apps, So we had different
issuer
andaudience
values for JWT validation based on these Azure AD apps. Which is fine.2. We Implemented JWT Validation in YARP using C# and .NET
Middleware to Validate JWT: In the YARP pipeline, we injected a middleware to inspect the
Authorization
header of the incoming request and validate the JWT token.Something like below
We used values for the issuer, audience, and signing key as hard coded in above. In a your scenario, you may need a more dynamic approach where these values change based on which API the request is targeting. This could involve maintaining a configuration or map of API paths to their corresponding Azure AD settings, and fetching them dynamically in the middleware.