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?
389 Views Asked by EmilioV At
1
There are 1 best solutions below
Related Questions in AZURE-ACTIVE-DIRECTORY
- MultipleTokensMatched exception when using default TokenCache
- How can I share Azure Active Directory authentication between server side and client script?
- Azure AD Change Password with patch call
- Azure Active Directory Login: Web App Permissions, User Consent not triggered
- ADALJS Error description:AADSTS65001: No permission to access user information is configured for 'clientId' application, or it is expired or revoked
- app is re-initializing the first time ADAL "protected" URL is accessed via $http
- Validate access token for WEB API protected by Azure AD
- Azure AD Graph API: Is it possible to enumerate all groups associated with an application role?
- Is is possible to use Azure AD as a SAML compliant Identity Provider?
- Microsoft Graph API Accessing basic info of a user that is outside tenancy
- RoundCube OAuth with Azure Active Directory
- Deploy Azure AD WebAPI to IIS, with Windows Authentication enabled, skips Azure AD Authentication
- How to change Is Multiple Resource Refresh Token to true in Azure AD authentication?
- Azure, login to separate accounts with one email
- How to setup nginx to authenticate users through Azure AD?
Related Questions in AZURE-AD-MSAL
- In theory, is it possible for Azure AD or B2C to leverage the Facebook SDK for auth?
- How should I determine if an MSAL account has an Exchange based email system? (got an exception)
- How do I customize the App icon that appears in MSAL v2 myapps.microsoft.com?
- How to use ConfidentialClientApplication to perform AppOnly requests to Graph (Group.ReadWrite.All)
- Can MSAL be used with my own authority (e.g. IdentityServer)
- MSAL with Angular2 : Refused to display in a frame because it set 'X-Frame-Options' to 'deny'
- Azure B2C Refresh Token Functionality Not Working In iOS Swift Sample App
- Stay logged in when using msal.js
- Using MSAL in a machine-to-machine scenario as a CSP
- Unable to locate the refresh token with Microsoft Graph
- Microsoft Graph API .NET - Able to pull all users (including myself), but not just me
- How to make API call to Partner Center from authorized Web API?
- Why does my application always end up calling Program.PublicClientApp.AcquireTokenAsync?
- How to get user information when authenticating with OneDrive SDK
- Native Facebook login and Azure AD B2C using MSAL
Related Questions in MICROSOFT-IDENTITY-WEB
- How to validate the audience in the YARP routes?
- Microsoft Identity with local account and mobile apps
- Adding claims for roles in a token obtained using MSAL?
- IdentityServer with inheritance design. Update-database error
- What is the best way to configure an application startup.cs to use both Azure AD and Azure B2C in .netcore? I am new to Identiy providers
- 'AuthenticationBuilder' does not contain a definition for 'AddMicrosoftIdentityWebApp'
- Calling a secured Web API on behalf of another Azure App Service
- Adding Permissions to Claims - Microsoft.Identity.Web & B2C
- Azure B2C SSO for Hosted Wasm Blazor and Classical Web Application
- Capture Events From Microsoft.Identity.Web Login/Logout
- MSAL4j - How to handle MsalThrottlingException?
- How to authenticate user using Microsoft Share To Teams Button?
- Microsoft Identity Web generating http instead of https for redirect_url
- When using DefaultAzureCredential, web app tries to use ManagedIdentityCredential on local computer
- Is it possible to set a discovery URI for token acquisition in Microsoft.Identity.Web?
Related Questions in MS-YARP
- Change Yarp Port number from 5000 when deploying
- YARP Not Working, Using .NET Upgrade Assistant
- How to validate the audience in the YARP routes?
- Yarp - single incoming request to multiple services
- Get JWT in YARP before making route - is that possible?
- Can Yarp dynamically set the handler.SSLOptions.ClientCertificate certificate value with the value from the builderContext.AddCertHeader?
- How to add credentials authorization when using yarp reverse proxy
- System.Web.HttpContext.Session is null with SystemWebAdapters v1.3.0 on .NET 8 yarp incremental upgrade
- Microsoft C# .NET YARP 504 Gateway error and Failover
- YARP authentication: how to refresh auth token
- Deploying Azure App Service Webjob Using .Net 6 Fails to Start "Failed to bind to address http://127.0.0.1:5000: address already in use"
- Yarp proxy does not log a redirect?
- The I/O operation has been aborted because of either a thread exit or an application request while trying to connect signalR endpoint through yarp
- Use YARP in kubernetes as a service plus ingress
- How can I make yarp match path case insensitive?
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)
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?
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
issuerandaudiencevalues 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
Authorizationheader 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.