Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #279 from AzureAD/dev
Browse files Browse the repository at this point in the history
Release 1.0.10
  • Loading branch information
tushargupta51 committed May 10, 2016
2 parents 24edd5e + fb56cec commit b03dd62
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This library is optimized for working together with AngularJS.

## The Library

This is a GA released version. The current version is **1.0.9**.
This is a GA released version. The current version is **1.0.10**.

You have multiple ways of getting ADAL JS:

Expand All @@ -18,10 +18,10 @@ Via NPM:
Via CDN:

<!-- Latest compiled and minified JavaScript -->
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.9/js/adal.min.js"></script>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.9/js/adal-angular.min.js"></script>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.10/js/adal.min.js"></script>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.10/js/adal-angular.min.js"></script>

CDN will be updated to latest version 1.0.9.
CDN will be updated to latest version 1.0.10.

Via Bower:

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adal-angular",
"version": "1.0.9",
"version": "1.0.10",
"homepage": "https://github.com/AzureAD/azure-activedirectory-library-for-js",
"authors": [
"MSOpentech"
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.0.10
==========================
Fixing infinite loop when refreshing tokens, adding extensibility for specifying anonymous endpoints

Version 1.0.9
==========================
Adding events for state mismatch and error responses. Fix for token renewal for app's backend. Making library available on NPM
Expand Down
4 changes: 2 additions & 2 deletions dist/adal-angular.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/adal.min.js

Large diffs are not rendered by default.

71 changes: 50 additions & 21 deletions lib/adal-angular.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//----------------------------------------------------------------------
// AdalJS v1.0.9
// AdalJS v1.0.10
// @preserve Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved
// Apache License 2.0
Expand Down Expand Up @@ -89,7 +89,6 @@ if (typeof module !== 'undefined' && module.exports) {
}

if (requestInfo.requestType !== _adal.REQUEST_TYPE.LOGIN) {
_adal._renewActive = false;
_adal.callback = $window.parent.AuthenticationContext().callback;
if (requestInfo.requestType === _adal.REQUEST_TYPE.RENEW_TOKEN) {
_adal.callback = $window.parent.callBackMappedToRenewStates[requestInfo.stateResponse];
Expand All @@ -108,6 +107,10 @@ if (typeof module !== 'undefined' && module.exports) {
} else if (requestInfo.parameters['id_token']) {
_adal.callback(_adal._getItem(_adal.CONSTANTS.STORAGE.ERROR_DESCRIPTION), requestInfo.parameters['id_token']);
return;
} else if (requestInfo.parameters['error']) {
_adal.callback(_adal._getItem(_adal.CONSTANTS.STORAGE.ERROR_DESCRIPTION), null);
_adal._renewFailed = true;
return;
}
}
} else {
Expand Down Expand Up @@ -147,10 +150,11 @@ if (typeof module !== 'undefined' && module.exports) {
// No callback. App resumes after closing or moving to new page.
// Check token and username
updateDataFromCache(_adal.config.loginResource);
if (!_adal._renewActive && !_oauthData.isAuthenticated && _oauthData.userName) {
if (!_oauthData.isAuthenticated && _oauthData.userName && !_adal._renewActive && !_adal._renewFailed) {
// Idtoken is expired or not present
_adal._renewActive = true;
_adal.acquireToken(_adal.config.loginResource, function (error, tokenOut) {
_adal._renewActive = false;
if (error) {
$rootScope.$broadcast('adal:loginFailure', 'auto renew failure');
} else {
Expand Down Expand Up @@ -185,29 +189,54 @@ if (typeof module !== 'undefined' && module.exports) {
return global.requireADLogin ? route.requireADLogin !== false : !!route.requireADLogin;
}

function isAnonymousEndpoint(url) {
if (_adal.config && _adal.config.anonymousEndpoints) {
for (var i = 0; i < _adal.config.anonymousEndpoints.length; i++) {
if (url.indexOf(_adal.config.anonymousEndpoints[i]) > -1) {
return true;
}
}
}
return false;
}

var routeChangeHandler = function (e, nextRoute) {
if (nextRoute && nextRoute.$$route && isADLoginRequired(nextRoute.$$route, _adal.config)) {
if (!_oauthData.isAuthenticated && !_adal._renewActive) {
_adal.info('Route change event for:' + $location.$$url);
loginHandler();
if (nextRoute && nextRoute.$$route) {
if (isADLoginRequired(nextRoute.$$route, _adal.config)) {
if (!_oauthData.isAuthenticated && !_adal._renewActive) {
_adal.info('Route change event for:' + $location.$$url);
loginHandler();
}
}
else {
if (nextRoute.$$route.templateUrl && !isAnonymousEndpoint(nextRoute.$$route.templateUrl)) {
_adal.config.anonymousEndpoints.push(nextRoute.$$route.templateUrl);
}
}
}
};

var stateChangeHandler = function (e, toState, toParams, fromState, fromParams) {
if (toState && isADLoginRequired(toState, _adal.config)) {
if (!_oauthData.isAuthenticated && !_adal._renewActive) {
// $location.$$url is set as the page we are coming from
// Update it so we can store the actual location we want to
// redirect to upon returning
$location.$$url = toState.url;

// Parameters are not stored in the url on stateChange so
// we store them
_adal._saveItem(_adal.CONSTANTS.STORAGE.START_PAGE_PARAMS, JSON.stringify(toParams));

_adal.info('State change event for:' + $location.$$url);
loginHandler();
if (toState) {
if (isADLoginRequired(toState, _adal.config)) {
if (!_oauthData.isAuthenticated && !_adal._renewActive) {
// $location.$$url is set as the page we are coming from
// Update it so we can store the actual location we want to
// redirect to upon returning
$location.$$url = toState.url;

// Parameters are not stored in the url on stateChange so
// we store them
_adal._saveItem(_adal.CONSTANTS.STORAGE.START_PAGE_PARAMS, JSON.stringify(toParams));

_adal.info('State change event for:' + $location.$$url);
loginHandler();
}
}
else {
if (toState.templateUrl && !isAnonymousEndpoint(toState.templateUrl)) {
_adal.config.anonymousEndpoints.push(toState.templateUrl);
}
}
}
};
Expand Down Expand Up @@ -300,6 +329,7 @@ if (typeof module !== 'undefined' && module.exports) {
config.headers = config.headers || {};

var resource = authService.getResourceForEndpoint(config.url);
authService.verbose('Url: ' + config.url + ' maps to resource: ' + resource);
if (resource === null) {
return config;
}
Expand All @@ -316,7 +346,6 @@ if (typeof module !== 'undefined' && module.exports) {
authService.info('login already start.');
return $q.reject('login in progress, cancelling the request');
} else {
// external endpoints
// delayed request to return after iframe completes
var delayedRequest = $q.defer();
authService.acquireToken(resource).then(function (token) {
Expand Down
Loading

0 comments on commit b03dd62

Please sign in to comment.