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

Login updates: Avoid the outdated login API and store access tokens #104

Merged
merged 7 commits into from
Dec 28, 2019

Conversation

penguin42
Copy link
Contributor

This actually should be split, but it's all login related.
Firstly avoid the r0 login API (issue #100)
Also, start storing access tokens instead/as well as passwords.
This way, if you have a valuable password (e.g. a matrix server wired to corporate login) then if you don't tick 'save password' then we still have the access token saved and can use that next time.

Synapse got r0/login in Jan 2016 (pull 459), so lets use it
instead of the ancient api/v1/login.

Fixes: matrix-org#100

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Add the 'whoami' api call, as a means to validate an access token

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Store the access token we get after login.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
_login_completed currently fills in the account data from the login
transaction and then kicks off the initial sync.

Split the code to do the initial sync out; we're going to need to use it
in a different case later on.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
By default purple asks for a password if there's none stored, but
when we use an access token we'll want to have no password prompt
at all.  To do this we flag OPT_PROTO_PASSWORD_OPTIONAL
and then have to handle the case with no password manually.

Mostly cribbed from jabber/auth_cyrus.c

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
If we've got a stored access token, try that (by testing with a 'whoami'
call) and if it fails fall back to passworded login.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
I'd seen a whoami or one time hit the 1k limit - I think possibly
in an error response from one time key uploads.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
@penguin42 penguin42 merged commit 1d23385 into matrix-org:master Dec 28, 2019
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.

1 participant