-
Notifications
You must be signed in to change notification settings - Fork 231
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
CredentialsManager function to clear and revoke the refresh token #312
Conversation
The unit tests need a little re-working to try and avoid the use of the now-deprecated |
@stevehobbsdev fix your tests, appear to be breaking for everything other than tvOS in Swift 5 😄 So they would also be failing locally then? Let me know if you want to pair on this. |
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.
Few areas to discuss
They needed a sprinkling of `waitUntil` blocks so that the tests didn't trip over themselves with clearing credentials asynchronously while other tests were running.
b9362cb
to
351f2d2
Compare
May fix timeout issue when running in CI environment
* Tests have been reverted to a previous state where they used `clear` to remove credentials between tests, now that `clear` is no longer depcreated * Appropriate use of `waitUntil` has been restored into the tests so that they run properly
…th0#312) * Added CredentialsManager.clearAndRevokeToken(), superceding .clear() * Added deprecation notice above the old clear() method * Added an example of `clearAndRevokeToken` to the readme * Fixed unit tests They needed a sprinkling of `waitUntil` blocks so that the tests didn't trip over themselves with clearing credentials asynchronously while other tests were running. * Reverted changes to icons and storyboard * Removed the default case in favour of .success * Bumped timeout values inline with other waitUntil calls May fix timeout issue when running in CI environment * Bumped timeout for clearAndRevoke for multi manager tests * Reversed 'clear' deprecation, reverted tests * Tests have been reverted to a previous state where they used `clear` to remove credentials between tests, now that `clear` is no longer depcreated * Appropriate use of `waitUntil` has been restored into the tests so that they run properly * Renamed clearAndRevokeToken to revoke, updated README * Applied readme changes based on review feedback * Added more detail to doc comments for revoke method * Reworded test spec for clarity
Changes
This PR adds a new method
revoke
toCredentialsManager
, which boths clears credentials and revokes the refresh token, if available. It accepts a callback for when the revocation call has finished.When called, it first checks to make sure that it has:
If there is no refresh token, then the credentials are cleared as normal without the revoke endpoint being called.
Otherwise, it uses its internal instance of
Authentication
to call therevoke
endpoint, passing the refresh token. If this call is successful, the credentials are cleared. If not, the credentials remain and the callback is invoked with an error.Use Case
The
revoke
function could be used in most cases where the user's session is to be cleared, as it's designed to clear credentials even if there is no refresh token. Usingclear
would be beneficial if the session is to be cleared but the developer explicitly does not want to revoke the refresh token.Usage
The PR adds one method to the CredentialsManager API:
Testing
Checklist