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-browser testing sample using msal-node to obtain tokens #2771

Merged
merged 5 commits into from Jan 5, 2021

Conversation

tnorling
Copy link
Collaborator

SPAs using msal-browser to obtain tokens don't have an easy way to test their protected pages or APIs without using something like puppeteer to navigate through the AAD sign-in pages. This PR demonstrates how someone could use msal-node's ROPC flow to obtain tokens on the backend and pre-populate local/session storage with tokens.

One new API is exposed on the msal-node TokenCache to retrieve the Key Value store to make this easier.

@github-actions github-actions bot added msal-node Related to msal-node package samples Related to the samples apps for the library. labels Dec 16, 2020
@tnorling tnorling linked an issue Dec 16, 2020 that may be closed by this pull request
7 tasks
@coveralls
Copy link

coveralls commented Dec 16, 2020

Coverage Status

Coverage increased (+12.8%) to 95.257% when pulling 2938971 on test-msal-browser-example into 39f54ad on dev.

@@ -88,6 +88,10 @@ export class TokenCache implements ISerializableTokenCache {
}
}

getKVStore(): CacheKVStore {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should add tests for this?

Copy link
Contributor

@jasonnutter jasonnutter left a comment

Choose a reason for hiding this comment

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

One question, otherwise looks good!

Copy link
Member

@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.

Exposing ROPC to users should strictly go with warnings to discourage this for any other authentication purposes except for testing.

@pkanher617
Copy link
Contributor

Exposing ROPC to users should strictly go with warnings to discourage this for any other authentication purposes except for testing.

I agree, I think we should make it clear that this should only be done for tests, not in a production app.

@tnorling
Copy link
Collaborator Author

Exposing ROPC to users should strictly go with warnings to discourage this for any other authentication purposes except for testing.

I agree, I think we should make it clear that this should only be done for tests, not in a production app.

I also agree. I've added a warning to the top of the sample readme

@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2021

This PR has not seen activity in 14 days. It may be closed if it remains stale.

@github-actions github-actions bot added the no-pr-activity PR has been inactive for 14 days label Jan 1, 2021
@tnorling tnorling removed the no-pr-activity PR has been inactive for 14 days label Jan 4, 2021
@tnorling tnorling merged commit 4f83e8d into dev Jan 5, 2021
@tnorling tnorling deleted the test-msal-browser-example branch January 5, 2021 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-node Related to msal-node package samples Related to the samples apps for the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prepopulate Cache Storage from E2E-Tests
5 participants