AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 374 forks source link

Suggestion on avoiding multiple token fetch #834

Closed riteshbhoi closed 5 years ago

riteshbhoi commented 5 years ago

Team, i am looking for a suggestion on for authentication scenario.

I have SPA coded using React JS using typescript. Authentication is implemented using ADAL JS and we are using session storage as cache location.

Existing Scenario - Every time user opens our website, we acquire token for user.

Desired Scenario - We want to store user token some where secure, so that we don't redirect user to acquire token if token is valid. I am not sure if using local storage is a suggested approach for this. Also websites like https://microsoftit.visualstudio.com/ doesnt store token either in local or session stores, but they dont redirect to acquire/refresh token whenever i browse them.

FDMatthias commented 5 years ago

Maybe this blogpost can help, with the necessary tweaking for your own desired scenario..

riteshbhoi commented 5 years ago

@CauseOfDev Thanks for your response. But i din't find answer to what i was looking for in attached article.

navyasric commented 5 years ago

@riteshbhoi ADAL.js handles the storing of tokens in the browser storage and so you don't have to explicitly store the tokens. The default storage location is sessionStorage but this does not allow session to be shared between browser tabs. For maintaining the stored tokens between the same session of the website, please configure the cacheLocation to be localStorage when initializing adal.js as shown here. Some websites maybe using other auth flows such as server side authentication. ADAL.js is meant to be used for client side authentication in browser based web apps such as SPAs.

riteshbhoi commented 5 years ago

thank you for your response. closing the issue.