Skip to content
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

[msal-common]Combine Request module for node and browser components #1682

Merged
merged 18 commits into from Jun 4, 2020

Conversation

sameerag
Copy link
Member

This PR aims to:

  • Maintain common requests for auth-code flow support in msal-node and msal-browser
  • Rewrite SPAClient.ts as a wrapper on top of AuthorizationCodeClient.ts
  • Delete ServerCodeRequestParameters.ts and ServerTokenRequestParameters.ts and have SPAClient.ts reference RequestParameterBuilder.ts instead

@sameerag
Copy link
Member Author

cc @pkanher617

try {
// Create auth code request and generate PKCE params
const authCodeRequest: AuthorizationCodeRequest = await this.generateAuthorizationCodeRequest(validRequest);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for now. When we add interactiveFlow which would need PKCE generation for msal-node we can think of migrating this to msal-common or have equivalent code in msal-node.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @sangonzal we need to track this for msal-node

} catch (err) {
throw BrowserAuthError.createTokenRequestCacheError(err);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this. All browser specific cache handling now is clearly demarcated between msal-common and msal-browser

// Acquire token with retrieved code.
return this.authModule.acquireToken(codeResponse);
const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, userState, cachedNonce);
Copy link
Member Author

@sameerag sameerag May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss nonce, I wonder why this is not applicable to node. I do understand that redirect use case for msal-browser poses unique challenges w.r.t application memory. Lets revisit this.

@@ -146,6 +147,9 @@ export class AuthorizationCodeClient extends BaseClient {
// add response_type = code
parameterBuilder.addResponseTypeCode();

// add library info parameters
parameterBuilder.addLibraryInfo(this.config.libraryInfo);

if (request.codeChallenge) {
RequestValidator.validateCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this validation also to ParameterBuilder as others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

throw ClientAuthError.createEndpointDiscoveryIncompleteError(e);
}
// Initialize authority or use default, and perform discovery endpoint check.
const acquireTokenAuthority = (codeRequest && codeRequest.authority) ? AuthorityFactory.createInstance(codeRequest.authority, this.networkClient) : this.defaultAuthority;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change once authority creation is platform specific as msal-node does; cc @sangonzal to help @pkanher617 if needed

this.spaCacheManager.resetTempCacheItems();
this.account = null;
throw e;
// Get current cached tokens
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI reviewers: This will change after silentFlow PR is up for msal-node.

Copy link
Member Author

@sameerag sameerag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please make sure ServerTokenRequestParameters and ServerCodeRequestParameters are deleted.

@pkanher617 pkanher617 marked this pull request as ready for review May 27, 2020 17:00
@github-actions github-actions bot added msal-browser Related to msal-browser package msal-common Related to msal-common package labels Jun 1, 2020
@pkanher617 pkanher617 changed the base branch from msal-node-cache-response to dev June 4, 2020 21:05
@DarylThayil
Copy link
Contributor

lots of files here, what needs to be reviewed?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.862% when pulling 8110eba on msal-node-merge-request into 5abfdbe on dev.

@sameerag sameerag merged commit 4468dd0 into dev Jun 4, 2020
@sameerag sameerag deleted the msal-node-merge-request branch June 8, 2020 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-browser Related to msal-browser package msal-common Related to msal-common package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants