There is a built-in design flaw in the type of MVC application I created, and I believe that I am not the first to understand it.
I have an MVC 4 application that uses AD Azure Authentication, which was introduced into the application as follows.
ASP.NET Application Development with Azure Active Directory
Once the user authenticates and Home.cshtml loads, KnockoutJs is used to execute JavaScript AJAX POST and GET requests to read and write data.
So it's not exactly a one-page application, but rather a combination of traditional postbacks for authenticating and servicing assets and read / write operations through AJAX.
During AJAX requests, the authentication token expires and AD cannot update the token through JavaScript.
The following browser error is observed
XMLHttpRequest cannot load https://login.windows.net/xxx . The requested resource does not have an Access-Control-Allow-Origin header. Therefore, Origin 'xxx' does not have access.
I studied adal.js and the following posts, but not sure if adal.js is a solution for my type of application or how best to enable it so that it works with my type of application.
My understanding so far:
I do not use AngularJS.
I am not starting authentication with JavaScript, and I am not authenticated with JavaScript to be able to use adal.js.
Authentication is done on the server side, and the subsequent OAuth2 update token mechanism requires full-text postbacks.
I stumbled upon various released posts from Vittorio Bertocci, but no one addresses the design features of this type of MVC application design.
ADAL, Windows Azure AD, and multi-resource token updates
WAAD does not update access token from javascript
Combination of ADAL.Net and ADAL.js
AngularJS + ADAL.JS sets the resource identifier (Audience)