|
107 | 107 |
|
108 | 108 | if (service.token !== null) { |
109 | 109 | if (!parsedFromHash || previousState == service.token.state) { |
110 | | - $rootScope.$broadcast('oauth2:authSuccess'); |
| 110 | + $rootScope.$broadcast('oauth2:authSuccess', service.token); |
111 | 111 | var oauthRedirectRoute = $window.sessionStorage.getItem('oauthRedirectRoute'); |
112 | 112 | if (oauthRedirectRoute && oauthRedirectRoute != "null") { |
113 | 113 | $window.sessionStorage.setItem('oauthRedirectRoute', null); |
|
210 | 210 | 'client_id=' + encodeURIComponent(params.clientId) + '&' + |
211 | 211 | 'redirect_uri=' + encodeURIComponent(params.redirectUrl) + '&' + |
212 | 212 | 'response_type=' + encodeURIComponent(params.responseType) + '&' + |
213 | | - 'scope=' + encodeURIComponent(params.scope) + '&' + |
214 | | - 'nonce=' + encodeURIComponent(params.nonce) + '&' + |
215 | | - 'state=' + encodeURIComponent(params.state); |
| 213 | + 'scope=' + encodeURIComponent(params.scope) + '&'; |
| 214 | + if (params.nonce) { |
| 215 | + service.url += 'nonce=' + encodeURIComponent(params.nonce) + '&'; |
| 216 | + } |
| 217 | + service.url += 'state=' + encodeURIComponent(params.state); |
216 | 218 | service.signOutUrl = params.signOutUrl; |
217 | 219 | service.signOutRedirectUrl = params.signOutRedirectUrl; |
218 | 220 | service.state = params.state; |
|
243 | 245 | signOutUrl: '@', // url on the authorization server for logging out. Local token is deleted even if no URL is given but that will leave user logged in against STS |
244 | 246 | signOutAppendToken: '@', // defaults to 'false', set to 'true' to append the token to the sign out url |
245 | 247 | signOutRedirectUrl: '@', // url to redirect to after sign out on the STS has completed |
246 | | - nonce: '@' // nonce value, optional |
| 248 | + nonce: '@', // nonce value, optional. If unspecified or an empty string and autoGenerateNonce is true then a nonce will be auto-generated |
| 249 | + autoGenerateNonce: '=' // Should a nonce be autogenerated if not supplied. Optional and defaults to true. |
247 | 250 | } |
248 | 251 | }; |
249 | 252 |
|
|
285 | 288 | scope.signOutRedirectUrl = scope.signOutRedirectUrl || ''; |
286 | 289 | scope.unauthorizedAccessUrl = scope.unauthorizedAccessUrl || ''; |
287 | 290 | scope.state = scope.state || generateState(); |
288 | | - scope.nonce = scope.nonce || generateState(); |
289 | | - |
| 291 | + if (scope.autoGenerateNonce === undefined) { |
| 292 | + scope.autoGenerateNonce = true; |
| 293 | + } |
| 294 | + if (!scope.nonce && scope.autoGenerateNonce) { |
| 295 | + scope.nonce = generateState(); |
| 296 | + } |
| 297 | + |
290 | 298 | compile(); |
291 | 299 |
|
292 | 300 | endpoint.init(scope); |
|
0 commit comments