From 78baae7bfb80bc89aa0ff00bf89d69d1c6253f61 Mon Sep 17 00:00:00 2001 From: Trevor Hudson Date: Thu, 19 Jan 2017 18:36:52 -0500 Subject: [PATCH] Remove dependancy on and add optional 'aud' to parameters --- dist/angularJsOAuth2.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/dist/angularJsOAuth2.js b/dist/angularJsOAuth2.js index d9c3e1e..c2e4158 100755 --- a/dist/angularJsOAuth2.js +++ b/dist/angularJsOAuth2.js @@ -203,7 +203,8 @@ 'client_id=' + encodeURIComponent(service.clientId) + '&' + 'redirect_uri=' + encodeURIComponent(performSilently?service.silentTokenRedirectUrl:service.redirectUrl) + '&' + 'response_type=' + encodeURIComponent(service.responseType) + '&' + - 'scope=' + encodeURIComponent(service.scope); + 'scope=' + encodeURIComponent(service.scope) + '&' + + 'aud=' + encodeURIComponent(service.aud); if (service.nonce) { url += '&nonce=' + encodeURIComponent(service.nonce); } @@ -294,6 +295,7 @@ service.silentTokenRedirectUrl= params.silentTokenRedirectUrl; service.signOutRedirectUrl = params.signOutRedirectUrl; service.state = params.state || generateState(); + service.aud = params.aud; if (params.signOutAppendToken == 'true') { service.appendSignoutToken = true; } @@ -304,11 +306,17 @@ // Open ID directive angular.module('oauth2.directive', []) - .config(['$routeProvider', function ($routeProvider) { - $routeProvider - .when('/silent-renew', { + .config(['$injector', function($injector){ + if ($injector.has('$routeProvider')){ + // If $routeProvider has been registered then allow silent renew + console.log('Has $routeProvider: Allowing for silent renew'); + $injector.get('$routeProvider').when('/silent-renew', { template: "" - }) + }); + } else { + // Otherwise don't do anything. + console.log('Skipping $routeProvider'); + } }]) .directive('oauth2', ['$rootScope', '$http', '$window', '$location', '$templateCache', '$compile', 'AccessToken', 'Endpoint', function($rootScope, $http, $window, $location, $templateCache, $compile, accessToken, endpoint) { var definition = { @@ -331,7 +339,8 @@ silentTokenRedirectUrl: '@', // url to use for silently renewing access tokens, default behaviour is not to do nonce: '@?', // nonce value, optional. If unspecified or an empty string and autoGenerateNonce is true then a nonce will be auto-generated autoGenerateNonce: '=?', // Should a nonce be autogenerated if not supplied. Optional and defaults to true. - tokenStorageHandler: '=' + tokenStorageHandler: '=', + aud: '@?' } }; @@ -339,10 +348,10 @@ function compile() { var tpl = ''; if (scope.template) { - $http.get(scope.template, { cache: $templateCache }).then(function(templateResult) { - element.html(templateResult.data); - $compile(element.contents())(scope); - }); + $http.get(scope.template, { cache: $templateCache }).success(function(html) { + element.html(html); + $compile(element.contents())(scope); + }); } else { element.html(tpl); $compile(element.contents())(scope); @@ -372,6 +381,7 @@ scope.signOutRedirectUrl = scope.signOutRedirectUrl || ''; scope.unauthorizedAccessUrl = scope.unauthorizedAccessUrl || ''; scope.silentTokenRedirectUrl = scope.silentTokenRedirectUrl || ''; + scope.aud = scope.aud || ''; if (scope.autoGenerateNonce === undefined) { scope.autoGenerateNonce = true; }