Skip to content

Extend acquireTokenHelper instrumentation #1752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 11, 2020
Merged
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/msal-core/src/UserAgentApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,12 @@ export class UserAgentApplication {
*
*/
private async acquireTokenHelper(account: Account, interactionType: InteractionType, isLoginCall: boolean, request: AuthenticationParameters, resolve?: any, reject?: any): Promise<void> {
this.logger.verbose("AcquireTokenHelper has been called");

// Track the acquireToken progress
this.cacheStorage.setItem(TemporaryCacheKeys.INTERACTION_STATUS, Constants.inProgress);
const scope = request.scopes ? request.scopes.join(" ").toLowerCase() : this.clientId.toLowerCase();
this.logger.verbosePii(`Serialized scopes: ${scope}`);

let serverAuthenticationRequest: ServerRequestParameters;
const acquireTokenAuthority = (request && request.authority) ? AuthorityFactory.CreateInstance(request.authority, this.config.auth.validateAuthority, request.authorityMetadata) : this.authorityInstance;
Expand Down Expand Up @@ -530,11 +533,14 @@ export class UserAgentApplication {
request.state,
request.correlationId
);
this.logger.verbose("Finished building server authentication request");

this.updateCacheEntries(serverAuthenticationRequest, account, isLoginCall, loginStartPage);
this.logger.verbose("Updating cache entries");

// populate QueryParameters (sid/login_hint) and any other extraQueryParameters set by the developer
serverAuthenticationRequest.populateQueryParams(account, request);
this.logger.verbose("Query parameters populated from account");

// Construct urlNavigate
const urlNavigate = UrlUtils.createNavigateUrl(serverAuthenticationRequest) + Constants.response_mode_fragment;
Expand All @@ -543,10 +549,12 @@ export class UserAgentApplication {
if (interactionType === Constants.interactionTypeRedirect) {
if (!isLoginCall) {
this.cacheStorage.setItem(`${TemporaryCacheKeys.STATE_ACQ_TOKEN}${Constants.resourceDelimiter}${request.state}`, serverAuthenticationRequest.state, this.inCookie);
this.logger.verbose("State cached for redirect");
}
} else if (interactionType === Constants.interactionTypePopup) {
window.renewStates.push(serverAuthenticationRequest.state);
window.requestType = isLoginCall ? Constants.login : Constants.renewToken;
this.logger.verbose("State saved to window");

// Register callback to capture results from server
this.registerCallback(serverAuthenticationRequest.state, scope, resolve, reject);
Expand All @@ -555,6 +563,7 @@ export class UserAgentApplication {
}

if (interactionType === Constants.interactionTypePopup) {
this.logger.verbose("Interaction type is popup. Generating popup window");
// Generate a popup window
try {
popUpWindow = this.openPopup(urlNavigate, "msal", Constants.popUpWidth, Constants.popUpHeight);
Expand Down