diff --git a/src/auth/progress.auth.azure.js b/src/auth/progress.auth.azure.js new file mode 100644 index 0000000..85bad0c --- /dev/null +++ b/src/auth/progress.auth.azure.js @@ -0,0 +1,76 @@ +(function(){ + + "use strict"; + + progress.data.AuthenticationProviderAzure = function(uri) { + var bearerToken; + + this._initialize(uri, progress.data.Session.AUTH_TYPE_AZURE, + {"_loginURI": progress.data.AuthenticationProvider._homeLoginURIBase}); + + function make_bearer_token_header() { + return "Bearer " + token; + } + + this._reset = function() { + bearerToken = null; + } + + this._openLoginRequest = function (xhr, uri) { + var auth; + + xhr.open("GET", uri, true); // but see comments below inside the "if userName" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_bearer_token_header_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + }; + + this._processLoginResult = function _azure_processLoginResult(xhr, deferred) { + progress.data.AuthenticationProviderAzure.prototype._processLoginResult.apply( + this, + [xhr, deferred] + ); + if (!this._loggedIn) { + bearerToken = null; + } + }; + + this.login = function (token) { + bearerToken = token; + return this._loginProto(); + } + + this._openRequestAndAuthorize = function (xhr, verb, uri, async, callback) { + var auth, + errorObject; + + xhr.open(verb, uri, async); // but see comments below inside the "if userName" + // may have to go with that approach + + if (bearerToken) { + + // set Authorization header + auth = make_bearer_token_header(bearerToken); + xhr.setRequestHeader('Authorization', auth); + } + + progress.data.Session._setNoCacheHeaders(xhr); + + callback(errorObject); + }; + }; + + function AzureProxy() {} + AzureProxy.prototype = progress.data.AuthenticationProvider.prototype; + progress.data.AuthenticationProviderAzure.prototype = new AzureProxy(); + + progress.data.AuthenticationProviderAzure.prototype.constructor = + progress.data.AuthenticationProviderAzure; +}) \ No newline at end of file diff --git a/src/auth/progress.auth.js b/src/auth/progress.auth.js index 637f37e..91f13c3 100644 --- a/src/auth/progress.auth.js +++ b/src/auth/progress.auth.js @@ -88,6 +88,9 @@ limitations under the License. case progress.data.Session.AUTH_TYPE_FORM_SSO: authProv = new progress.data.AuthenticationProviderSSO(initObject.uri); break; + case progress.data.Session.AUTH_TYPE_AZURE: // NA - 03/2018 + authProv = new progress.data.AuthenticationProviderAzure(initObject.uri); + break; default: // AuthenticationProvider: The 'init-object' parameter passed to the 'constructor' function // has an invalid value for the 'authenticationModel' property. diff --git a/src/progress.session.js b/src/progress.session.js index c0680b6..6ec886d 100644 --- a/src/progress.session.js +++ b/src/progress.session.js @@ -1546,6 +1546,10 @@ limitations under the License. this.authenticationModel = this.authenticationModel.toLowerCase(); } + if (this.authenticationModel === progress.data.Session.AUTH_TYPE_AZURE) { + console.log("New type voor Azure"); + } + if (this.authenticationModel === progress.data.Session.AUTH_TYPE_SSO) { // Session: Cannot call login() when authenticationModel is SSO. // Please use the AuthenticationProvider object instead. @@ -3411,7 +3415,9 @@ limitations under the License. Object.defineProperty(progress.data.Session, 'AUTH_TYPE_FORM_SSO', { value: "form_sso", enumerable: true }); - + Object.defineProperty(progress.data.Session, 'AUTH_TYPE_AZURE', { // NA - 03/2018 + value: "azure", enumerable: true + }); Object.defineProperty(progress.data.Session, 'DEVICE_OFFLINE', { value: "Device is offline", enumerable: true @@ -3443,6 +3449,7 @@ limitations under the License. progress.data.Session.AUTH_TYPE_BASIC = "basic"; progress.data.Session.AUTH_TYPE_FORM = "form"; progress.data.Session.AUTH_TYPE_SSO = "sso"; + progress.data.Session.AUTH_TYPE_AZURE = "azure"; /* deliberately not including the "offline reasons" that are defined in the * 1st part of the conditional. We believe that we can be used only in environments where