Search code examples
azureidentityserver4asp.net-core-webapiazure-api-management

User Authentication with IdentityServer and Azure API Management


I need some help with Azure API Management service.

At the moment we have a SinglePage App which is using two Backend Services (WebApi .Net Core) hosted on Azure. To Authenticate and Authrize user we are using IdentityServer (also hosted on Azure as a service) + SubscriptionService. Here IdSrv is authenticating the user and it also defines to which APIs the webapp has access. The SubscriptionService has information if the user has rights to given APIs. More or less like that.

So the flow is: WebApp -> redirect to IdSrv endpoint -> login -> back to UI -> ask backend with user credentials (token)

Now, we want to add Azure API Management to the mix and I am struggling how to do that...

Initially we were thinking that we can hide everything including the IdentityServer behind API Management gateway, but looks like this doesn't make sense or is impossible. I found this as a helpfull reference: Generate Access Token and validate against IdentityServer4 through Azure API Management in which the second answer is quite important remark.

Based on that I think that I need to leave the Client to use IdentityServer to authenticate as this requires UI interaction but then somehow set a global policy in API Management to authorize the user using mentioned Send-Request policy. And then change backend to accept the JWT tokens from this policy? Is my thinking correct? How to implement that?

Or I should just pass the authorization-header from client request through API Management?

All those things are new for me so it could be that I missed something or messed up the terms...


Solution

  • it is quite late from asking this question but here I described how we have done that. We cover UI clients and Device clients with SSL Certification auth on APIM. In short words:

    • UI Client is being redirected to ID Server Loging page
    • APIM is doing Token validation with ID Server
    • APIM is doing SSL Certification verification in DB and returning back token like data for devices to pass some "device account" information.

    More details can be found here: