Need help integrating Azure SSO into an AngularJS application

473 Views Asked by At

I am trying to integrate Azure SSO into a new AngularJS application and I am struggling to find complete AngularJS examples that aren't written in Visual Studio. Anything that I come across is either incomplete and doesn't show how to deal with authenticated users, redirects, etc., or is in Visual Studio (which I don't want).

I have followed the tutorial for ADAL located here but it doesn't give a complete demonstration (only code fragments) and doesn't really explain how to deal with authenticated users. Is there anywhere I can find a complete AngularJS tutorial of how to integrate all features of Azure SSO?

I can get my app to call the microsoft login page, select my user and then request a password, but once that occurs, I am struggling with the Redirect URI. I am using UI-Router which means all my views are in the form of https://myapp.com/#!/auth which Azure claims is not a valid URL to redirect to.

If I change my Redirect URI to anything past the base root (e.g. https://myapp.com/auth/) I get an error every time I try and login:

AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application

If I leave it as root, my application falls back to https://myapp.com/#!/ and doesn't recognise the logged in user.

Does anyone have any suggestions or can assist me in getting this integrated? Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

I managed to resolve this by adding the following command to my .config() method:

$locationProvider.html5Mode(false).hashPrefix('');

This removed the ! from all my views and by making sure my application URL and redirect URL was the same in Azure (as recommended by @Sruthi J), this allowed the redirect to occur correctly.