Integrate angular - SPA with Azure AD + ADFS

Madhur 41 Reputation points
2020-05-13T17:07:10.513+00:00

Hi,

I want to integrate my angular- SPA with Azure AD which is federating with on-prem ADFS. as per online document seamless SSO is not available with ADFS. how can i achieve seamless SSO experience using AAD/ADFS , is it cookies based authentication ?

Any online document or sample application?

Regard,
Madhur

Microsoft Security Active Directory Federation Services
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. soumi-MSFT 11,831 Reputation points Microsoft Employee Moderator
    2020-05-21T08:08:44.36+00:00

    anonymous userBhardwaj-9418, I apologize for the delay in my response. Somehow I missed this thread. Let me try to share the answers for the questions listed above.

    1) But how to enable application specific SSO ?
    Ans: Application Specific SSO mostly works with apps using OAuth. When an app uses OAuth, mostly it would work on tokens. the two major tokens used are access tokens and refresh tokens. Using the refresh tokens another access token is requested for silently in the background, hence saving the user from logging in again in the middle of his session. Application specific SSO is enabled by default if your OAuth application uses Auth-Code Grant flow, which is a interactive login for users.

    2) If the token issued is valid for let's say 1 hour , and user tries to re-launch application after 4 hours. how silent authentication will work, does ADFS will re-issue new token using refresh token if that is still valid.
    Ans: If the user has accessed the application now, after logging in, he would be issued with an access token (valid for 1 hr by default) and a refresh token (valid for 14 days and keeps increasing if the refresh token keeps getting used). If the user closes the application/browser session, that session gets destroyed there and if after 4 hours the user again tries to access that same app, he would have to re-authenticate as the refresh token wont work here since the session was destroyed. Refresh token would only work if the session is active and just before the access token expires the code of the app fetches the next access token using the refresh token that rests in the application cache.

    3) how the refresh token is created, do we need to enable this also , or it is created by default with session and persistent SSO.
    Ans: If you are coding your own application, then you would need to use the MSAL library, which can be used to make the token requests. In that case, nothing special has to be done. But in case you are trying to fetch a token for an OAuth app using http post request, then you would need to add "offline_access" as a value for the scope parameter.

    Sample Request: https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize?client_id={client-id}&response_type=code&redirect_uri={redirect-uri}&response_mode=fragment&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2F.default&state=12345

    4) What changes do we need at ADAL side ? domain-hint/login-hint etc. Could you please point me to some sample application.
    Ans: You can check the following sample code. Its of a browser based application using MSAL(since this is the latest library) using Open ID Connect.
    You can also check the following URLs:

    Though these samples are for Azure AD, but these also work for ADFS. For enabling OpenID Connect on ADFS 2016, you can try the steps mentioned in the following article:
    https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/development/enabling-oauth-confidential-clients-with-ad-fs

    Hope this helps. Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as "Answer" if the above response helped in answering your query.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. soumi-MSFT 11,831 Reputation points Microsoft Employee Moderator
    2020-05-14T06:33:52.37+00:00

    anonymous userbhardwaj, You would also get SSO if the domain present in your Azure AD tenant is federated with ADFS. ADFS supports the following types of SSO:

    • Session SSO
    • Persistent SSO
    • Application SSO

    You can read more about ADFS SSO here.

    Hope this helps. Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as "Answer" if the above response helped in answering your query.

    1 person found this answer helpful.

  2. Muthu, Sathiamoorthy 1 Reputation point
    2020-09-08T10:53:33.193+00:00

    Hi @soumi-MSFT , I have successfully added MSAL in my SPA application, is it possible to add SAML? how to add SAML in SPA application?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.