Can I use authentication across multiple services from one web application?

Viewed 420

This seems like it would be a common scenario but I can't figure out how to get it work.

I have a Common Web Service located at origin 1. I want this to be common between multiple web applications. It has authentication turned on.

I then have Web Application located at origin 2. I want this web application to make some calls across to Common at origin 1 (via javascript)

These calls work fine if I turn off authentication for Common at origin 1. If I turn it on, it fails since the web application will not send the authentication cookie (or token?) across origins.

What is the correct way to architect this?

1 Answers

You want to look into what is called delegation. The scenario works like this:

  1. User authenticates against AAD in your front-end app
  2. A token gets issued that is valid for the front-end app and the backend-app (this is the delegation)
  3. You use the token provided and forward it to the backend-app and issue the request on behalf of the user

How to set this scenario up is described here but you really do not need API Management in the middle. The reason for using APIM makes sense if you want to expose your API to the outside world too or have multiple APIs that need to act as one facade.

Related