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

BREAKING CHANGE: set signOut option clearTokensAfterRedirect default to true #1059

Conversation

shuowu
Copy link
Contributor

@shuowu shuowu commented Jan 12, 2022

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2022

Codecov Report

Merging #1059 (876b269) into dev-6 (d05d815) will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            dev-6    #1059      +/-   ##
==========================================
+ Coverage   92.42%   92.53%   +0.10%     
==========================================
  Files         134      134              
  Lines        3722     3722              
  Branches      775      775              
==========================================
+ Hits         3440     3444       +4     
+ Misses        282      278       -4     
Impacted Files Coverage Δ
lib/OktaAuth.ts 89.16% <100.00%> (ø)
lib/TokenManager.ts 96.49% <0.00%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d05d815...876b269. Read the comment docs.

@shuowu-okta shuowu-okta force-pushed the sw-set-clearTokensAfterRedirect-default-to-true-OKTA-459787 branch from 6680448 to e8501b2 Compare January 12, 2022 18:25
@@ -109,7 +109,7 @@

function logout(e) {
e.preventDefault();
authClient.signOut()
authClient.signOut({ clearTokensBeforeRedirect: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

This is because we are not running start() by default, right? Can you add a small comment explaining why we are passing true here.

expect(auth.revokeRefreshToken).not.toHaveBeenCalled();
expect(auth.revokeAccessToken).toHaveBeenCalledWith(accessToken);
expect(auth.tokenManager.clear).toHaveBeenCalled();
expect(auth.tokenManager.clear).not.toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

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

since this assertion is being reversed, can we update the title to include this information?

Default options: will X, Y, and set tokens to clear after redirect

add an assert that the pending token renew was saved

Copy link
Contributor

Choose a reason for hiding this comment

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

alternatively, can remove the tokenManager asserts from this test since this logic is covered in another test

expect(auth.revokeAccessToken).toHaveBeenCalledWith(accessToken);
expect(auth.revokeRefreshToken).toHaveBeenCalledWith(refreshToken);
expect(auth.tokenManager.clear).toHaveBeenCalled();
expect(auth.tokenManager.clear).not.toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

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

same as comment above, please update title and add assertion for pending state

Copy link
Contributor

@aarongranick-okta aarongranick-okta left a comment

Choose a reason for hiding this comment

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

code and docs look good.

please update test to either remove tokenManager assert or add language in test title to include token behavior

CHANGELOG.md Outdated
@@ -9,6 +9,9 @@
- [#1050](https://github.com/okta/okta-auth-js/pull/1050) Removes `userAgent` field from oktaAuth instance
- [#1014](https://github.com/okta/okta-auth-js/pull/1014) Shared transaction storage is automatically cleared on success and error states. Storage is not cleared for "terminal" state which is neither success nor error.
- [#1051](https://github.com/okta/okta-auth-js/pull/1051) Removes `useMultipleCookies` from CookieStorage options
- [#1059](https://github.com/okta/okta-auth-js/pull/1059)
- Removes signOut option `clearTokensAfterRedirect`
- Adds signOut option `clearTokensAfterRedirect` (default: `false`) to remove local tokens before logout redirect happen
Copy link
Contributor

Choose a reason for hiding this comment

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

should say clearTokensBeforeRedirect here

expect(window.location.assign).toHaveBeenCalledWith(`${issuer}/oauth2/v1/logout?id_token_hint=${idToken.idToken}&post_logout_redirect_uri=${encodedOrigin}`);
});
});

it('Can pass a "clearTokensAfterRedirect=true" to skip clear tokens logic', function() {
it('skips token clear logic by default', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not skipping the logic, it is adding a pending remove flag. Let's make sure the test title matches as closely as possible to the assertions that we are making

By default, does not clear tokens before redirect but sets a pending remove flag

.then(function() {
expect(auth.tokenManager.clear).not.toHaveBeenCalled();
expect(auth.tokenManager.addPendingRemoveFlags).toHaveBeenCalled();
expect(window.location.assign).toHaveBeenCalledWith(`${issuer}/oauth2/v1/logout?id_token_hint=${idToken.idToken}&post_logout_redirect_uri=${encodedOrigin}`);
});
});

it('Can pass a "clearTokensAfterRedirect=false" to force clear tokens logic', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

if 'clearTokensBeforeRedirect' is true, then tokens will be cleared and pending remove flag will not be set

Copy link
Contributor

@aarongranick-okta aarongranick-okta left a comment

Choose a reason for hiding this comment

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

just a few wording changes

eng-prod-CI-bot-okta pushed a commit that referenced this pull request Jan 13, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
shuowu-okta pushed a commit that referenced this pull request Jan 14, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
aarongranick-okta pushed a commit that referenced this pull request Jan 14, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
shuowu-okta pushed a commit that referenced this pull request Jan 18, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
aarongranick-okta pushed a commit that referenced this pull request Jan 19, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
aarongranick-okta pushed a commit that referenced this pull request Jan 19, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
aarongranick-okta pushed a commit that referenced this pull request Jan 20, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"
eng-prod-CI-bot-okta pushed a commit that referenced this pull request Jan 20, 2022
…to true

OKTA-459787
<<<Jenkins Check-In of Tested SHA: 3bb06dc for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 7
PR Link: "#1059"

OKTA-383487
<<<Jenkins Check-In of Tested SHA: f1b290b for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-auth-js
Files changed count: 235
PR Link: "#1053"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants