Skip to content

Commit 84dd6a2

Browse files
authored
Merge branch 'dev' into cloud-discovery
2 parents 2e16854 + 8c86372 commit 84dd6a2

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

build/sdl-tasks.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ steps:
1010
optionsXS: 1
1111
optionsHMENABLE: 0
1212

13-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
14-
displayName: 'Run CredScan3'
15-
inputs:
16-
scanFolder: './'
17-
debugMode: false
13+
# - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
14+
# displayName: 'Run CredScan3'
15+
# inputs:
16+
# scanFolder: './'
17+
# debugMode: false
1818

1919
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
2020
displayName: 'Post Analysis'
2121
inputs:
22-
CredScan: true
22+
CredScan: false
2323
PoliCheck: true

lib/msal-core/src/UserAgentApplication.ts

+46-6
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,46 @@ export class UserAgentApplication {
288288
* @param hash
289289
*/
290290
public urlContainsHash(hash: string) {
291+
this.logger.verbose("UrlContainsHash has been called");
291292
return UrlUtils.urlContainsHash(hash);
292293
}
293294

294295
private authResponseHandler(interactionType: InteractionType, response: AuthResponse, resolve?: any) : void {
296+
this.logger.verbose("AuthResponseHandler has been called");
297+
295298
if (interactionType === Constants.interactionTypeRedirect) {
299+
this.logger.verbose("Interaction type is redirect");
296300
if (this.errorReceivedCallback) {
301+
this.logger.verbose("Two callbacks were provided to handleRedirectCallback, calling success callback with response");
297302
this.tokenReceivedCallback(response);
298303
} else if (this.authResponseCallback) {
304+
this.logger.verbose("One callback was provided to handleRedirectCallback, calling authResponseCallback with response");
299305
this.authResponseCallback(null, response);
300306
}
301307
} else if (interactionType === Constants.interactionTypePopup) {
308+
this.logger.verbose("Interaction type is popup, resolving");
302309
resolve(response);
303310
} else {
304311
throw ClientAuthError.createInvalidInteractionTypeError();
305312
}
306313
}
307314

308315
private authErrorHandler(interactionType: InteractionType, authErr: AuthError, response: AuthResponse, reject?: any) : void {
316+
this.logger.verbose("AuthErrorHandler has been called");
317+
309318
// set interaction_status to complete
310319
this.cacheStorage.removeItem(TemporaryCacheKeys.INTERACTION_STATUS);
311320
if (interactionType === Constants.interactionTypeRedirect) {
321+
this.logger.verbose("Interaction type is redirect");
312322
if (this.errorReceivedCallback) {
323+
this.logger.verbose("Two callbacks were provided to handleRedirectCallback, calling error callback");
313324
this.errorReceivedCallback(authErr, response.accountState);
314325
} else {
326+
this.logger.verbose("One callback was provided to handleRedirectCallback, calling authResponseCallback with error");
315327
this.authResponseCallback(authErr, response);
316328
}
317329
} else if (interactionType === Constants.interactionTypePopup) {
330+
this.logger.verbose("Interaction type is popup, rejecting");
318331
reject(authErr);
319332
} else {
320333
throw ClientAuthError.createInvalidInteractionTypeError();
@@ -327,6 +340,8 @@ export class UserAgentApplication {
327340
* @param {@link (AuthenticationParameters:type)}
328341
*/
329342
loginRedirect(userRequest?: AuthenticationParameters): void {
343+
this.logger.verbose("LoginRedirect has been called");
344+
330345
// validate request
331346
const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypeRedirect);
332347
this.acquireTokenInteractive(Constants.interactionTypeRedirect, true, request, null, null);
@@ -339,6 +354,8 @@ export class UserAgentApplication {
339354
* To renew idToken, please pass clientId as the only scope in the Authentication Parameters
340355
*/
341356
acquireTokenRedirect(userRequest: AuthenticationParameters): void {
357+
this.logger.verbose("AcquireTokenRedirect has been called");
358+
342359
// validate request
343360
const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, false, this.clientId, Constants.interactionTypeRedirect);
344361
this.acquireTokenInteractive(Constants.interactionTypeRedirect, false, request, null, null);
@@ -352,6 +369,8 @@ export class UserAgentApplication {
352369
* @returns {Promise.<AuthResponse>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object
353370
*/
354371
loginPopup(userRequest?: AuthenticationParameters): Promise<AuthResponse> {
372+
this.logger.verbose("LoginPopup has been called");
373+
355374
// validate request
356375
const request: AuthenticationParameters = RequestUtils.validateRequest(userRequest, true, this.clientId, Constants.interactionTypePopup);
357376
const apiEvent: ApiEvent = this.telemetryManager.createAndStartApiEvent(request.correlationId, API_EVENT_IDENTIFIER.LoginPopup);
@@ -360,6 +379,7 @@ export class UserAgentApplication {
360379
this.acquireTokenInteractive(Constants.interactionTypePopup, true, request, resolve, reject);
361380
})
362381
.then((resp) => {
382+
this.logger.verbose("Successfully logged in");
363383
this.telemetryManager.stopAndFlushApiEvent(request.correlationId, apiEvent, true);
364384
return resp;
365385
})
@@ -652,6 +672,8 @@ export class UserAgentApplication {
652672
* @param request
653673
*/
654674
ssoSilent(request: AuthenticationParameters): Promise<AuthResponse> {
675+
this.logger.verbose("ssoSilent has been called");
676+
655677
// throw an error on an empty request
656678
if (!request) {
657679
throw ClientConfigurationError.createEmptyRequestError();
@@ -1020,6 +1042,7 @@ export class UserAgentApplication {
10201042
* Default behaviour is to redirect the user to `window.location.href`.
10211043
*/
10221044
logout(correlationId?: string): void {
1045+
this.logger.verbose("Logout has been called");
10231046
this.logoutAsync(correlationId);
10241047
}
10251048

@@ -1044,15 +1067,28 @@ export class UserAgentApplication {
10441067

10451068
const correlationIdParam = `client-request-id=${requestCorrelationId}`;
10461069

1047-
const postLogoutQueryParam = this.getPostLogoutRedirectUri()
1048-
? `&post_logout_redirect_uri=${encodeURIComponent(this.getPostLogoutRedirectUri())}`
1049-
: "";
1070+
let postLogoutQueryParam: string;
1071+
if (this.getPostLogoutRedirectUri()) {
1072+
postLogoutQueryParam = `&post_logout_redirect_uri=${encodeURIComponent(this.getPostLogoutRedirectUri())}`;
1073+
this.logger.verbose("redirectUri found and set");
1074+
} else {
1075+
postLogoutQueryParam = "";
1076+
this.logger.verbose("No redirectUri set for app. postLogoutQueryParam is empty");
1077+
}
10501078

1051-
const urlNavigate = this.authorityInstance.EndSessionEndpoint
1052-
? `${this.authorityInstance.EndSessionEndpoint}?${correlationIdParam}${postLogoutQueryParam}`
1053-
: `${this.authority}oauth2/v2.0/logout?${correlationIdParam}${postLogoutQueryParam}`;
1079+
let urlNavigate: string;
1080+
if (this.authorityInstance.EndSessionEndpoint) {
1081+
urlNavigate = `${this.authorityInstance.EndSessionEndpoint}?${correlationIdParam}${postLogoutQueryParam}`;
1082+
this.logger.verbose("EndSessionEndpoint found and urlNavigate set");
1083+
this.logger.verbosePii(`urlNavigate set to: ${this.authorityInstance.EndSessionEndpoint}`);
1084+
} else {
1085+
urlNavigate = `${this.authority}oauth2/v2.0/logout?${correlationIdParam}${postLogoutQueryParam}`;
1086+
this.logger.verbose("No endpoint, urlNavigate set to default");
1087+
}
10541088

10551089
this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, true);
1090+
1091+
this.logger.verbose("Navigating window to urlNavigate");
10561092
this.navigateWindow(urlNavigate);
10571093
} catch (error) {
10581094
this.telemetryManager.stopAndFlushApiEvent(requestCorrelationId, apiEvent, false, error.errorCode);
@@ -1065,6 +1101,7 @@ export class UserAgentApplication {
10651101
* @ignore
10661102
*/
10671103
protected clearCache(): void {
1104+
this.logger.verbose("Clearing cache");
10681105
window.renewStates = [];
10691106
const accessTokenItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);
10701107
for (let i = 0; i < accessTokenItems.length; i++) {
@@ -1073,6 +1110,7 @@ export class UserAgentApplication {
10731110
this.cacheStorage.resetCacheItems();
10741111
// state not being sent would mean this call may not be needed; check later
10751112
this.cacheStorage.clearMsalCookie();
1113+
this.logger.verbose("Cache cleared");
10761114
}
10771115

10781116
/**
@@ -1082,11 +1120,13 @@ export class UserAgentApplication {
10821120
* @param accessToken
10831121
*/
10841122
protected clearCacheForScope(accessToken: string) {
1123+
this.logger.verbose("Clearing access token from cache");
10851124
const accessTokenItems = this.cacheStorage.getAllAccessTokens(Constants.clientId, Constants.homeAccountIdentifier);
10861125
for (let i = 0; i < accessTokenItems.length; i++) {
10871126
const token = accessTokenItems[i];
10881127
if (token.value.accessToken === accessToken) {
10891128
this.cacheStorage.removeItem(JSON.stringify(token.key));
1129+
this.logger.verbosePii(`Access token removed: ${token.key}`);
10901130
}
10911131
}
10921132
}

0 commit comments

Comments
 (0)