-
Notifications
You must be signed in to change notification settings - Fork 273
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
BREAKING CHANGE: set signOut option clearTokensAfterRedirect default to true #1059
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
f1bf054
to
d05d815
Compare
6680448
to
e8501b2
Compare
@@ -109,7 +109,7 @@ | |||
|
|||
function logout(e) { | |||
e.preventDefault(); | |||
authClient.signOut() | |||
authClient.signOut({ clearTokensBeforeRedirect: true }) |
There was a problem hiding this comment.
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.
test/spec/OktaAuth/browser.ts
Outdated
expect(auth.revokeRefreshToken).not.toHaveBeenCalled(); | ||
expect(auth.revokeAccessToken).toHaveBeenCalledWith(accessToken); | ||
expect(auth.tokenManager.clear).toHaveBeenCalled(); | ||
expect(auth.tokenManager.clear).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
test/spec/OktaAuth/browser.ts
Outdated
expect(auth.revokeAccessToken).toHaveBeenCalledWith(accessToken); | ||
expect(auth.revokeRefreshToken).toHaveBeenCalledWith(refreshToken); | ||
expect(auth.tokenManager.clear).toHaveBeenCalled(); | ||
expect(auth.tokenManager.clear).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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
test/spec/OktaAuth/browser.ts
Outdated
.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() { |
There was a problem hiding this comment.
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
There was a problem hiding this 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
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059"
…to true OKTA-459787 <<<Jenkins Check-In of Tested SHA: 3bb06dc for [email protected]>>> Artifact: okta-auth-js Files changed count: 7 PR Link: "#1059" OKTA-383487 <<<Jenkins Check-In of Tested SHA: f1b290b for [email protected]>>> Artifact: okta-auth-js Files changed count: 235 PR Link: "#1053"
No description provided.