rootinc / laravel-azure-middleware

94 stars 39 forks source link

Using one Azure app for multiple domains #61

Open maxi032 opened 2 years ago

maxi032 commented 2 years ago

How can I use 1 single Azure app to login to multiple websites? We have 2 CMS backends I wonder if it is possible to use the same Azure app to login to both of them since the content editors are all from the same Azure organization and the CMSs are using the same codebase (different .env files for each)

For that I've made an azure app with different Redirect URIs Example:

https://cmsportal1.example/login/azurecallback
https://cmsportal2.example/login/azurecallback

When I try to login to the cmsportal1 I am redirected to the second url from the list.

dickalexei commented 2 years ago

Hi,

Did you specify the "redirect_uri" parameter on you "authorize" request? Both URL are welle declared on your Azure portal as redirect?

janzikmund commented 1 year ago

@maxi032 - this seems already mostly implemented in master branch, but it's missing in latest release 0.9.10. So until a new release is made with this feature included, you can install the package using composer require rootinc/laravel-azure-middleware:dev-master.

That will give you latest master branch, where these changes are responsible to pass your azure.callback route as return_uri to the server.

As long as all the return urls are defined in your Redirect URIs on Azure app, Azure should respect that and send each authentication back to its original app.

Unfortunately looks like redirect_uri is only appended to general routes authentication, but not to the initial login itself. I made a PR here that should fix it, so let's see if it gets approved.