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

Add functions to support refresh tokens #2178

Merged
merged 5 commits into from
Feb 15, 2022
Merged

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Feb 15, 2022

MSC: matrix-org/matrix-spec-proposals#2918 (stable, but not formalized)
For element-hq/element-web#18698
For matrix-org/matrix-react-sdk#7802


Here's what your changelog entry will look like:

✨ Features

  • Add functions to support refresh tokens (#2178).

@turt2live turt2live changed the title Travis/refresh tokens idb Add functions to support refresh tokens Feb 15, 2022
@turt2live turt2live marked this pull request as ready for review February 15, 2022 03:41
@turt2live turt2live requested a review from a team as a code owner February 15, 2022 03:41
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
@turt2live turt2live enabled auto-merge (squash) February 15, 2022 20:02
@turt2live turt2live merged commit e86d886 into develop Feb 15, 2022
@turt2live turt2live deleted the travis/refresh-tokens-idb branch February 15, 2022 20:07
turt2live added a commit to matrix-org/matrix-react-sdk that referenced this pull request Feb 15, 2022
MSC: matrix-org/matrix-spec-proposals#2918
Fixes element-hq/element-web#18698
Fixes element-hq/element-web#20648
**Requires matrix-org/matrix-js-sdk#2178

**Note**: There's a lot of logging in this PR. That is intentional to ensure that if/when something goes wrong we can chase the exact code path. It does not log any tokens - just where the code is going. Overall, it should be fairly low volume spam (and can be relaxed at a later date).

----

This approach uses indexeddb (through a mutex library) to manage which tab actually triggers the refresh, preventing issues where multiple tabs try to update the token. If multiple tabs update the token then the server might consider the account hacked and hard logout all the tokens.

If for some reason the timer code gets it wrong, or the user has been offline for too long and the token can't be refreshed, they should be sent to a soft logout screen by the server. This will retain the user's encryption state - they simply need to reauthenticate to get an active access token again.

This additionally contains a change to fix soft logout not working, per the issue links above.

Of interest may be the IPC approach which was ultimately declined in favour of this change instead: #7803
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Mar 5, 2022
* Return send event response from MSC3089Branch.createNewVersion() ([\matrix-org#2186](matrix-org#2186)).
* Add functions to support refresh tokens ([\matrix-org#2178](matrix-org#2178)).
* [Release] Fix bug with the /hierarchy API sending invalid requests ([\matrix-org#2202](matrix-org#2202)).
* Fix bug where calls could break if rejected from somewhere else ([\matrix-org#2189](matrix-org#2189)).
* Fix camera stuck on after call transfer ([\matrix-org#2188](matrix-org#2188)).
* Fix synthetic read receipt handling ([\matrix-org#2174](matrix-org#2174)). Fixes element-hq/element-web#21016.
* Revert "Sign backup with cross-signing key when we reset it." ([\matrix-org#2175](matrix-org#2175)).
* Sign backup with cross-signing key when we reset it. ([\matrix-org#2170](matrix-org#2170)).
* Fix error in uploadContent() when file is empty under Node.js ([\matrix-org#2155](matrix-org#2155)).
* Check the backup info against the stored private key when determining trust. ([\matrix-org#2167](matrix-org#2167)).
* Back up keys before logging out ([\matrix-org#2158](matrix-org#2158)). Fixes element-hq/element-web#13151.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants