-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Implement /login/get_token
#664
Conversation
The entire flow can be verified to work like so: let password = "<password>"
let identifier = {"type":"m.id.user","user":"@<user>:localhost" }
let first_login = http post "http://localhost:8008/_matrix/client/v3/login" { type: "m.login.password", password: $password, identifier: $identifier, "initial_device_display_name": "test (password)" } -f -e --content-type application/json
let token_request = http post "http://localhost:8008/_matrix/client/v1/login/get_token" -H [Authorization $"Bearer ($first_login.body.access_token)"] {"auth":{"type":"m.login.password","password":$password, identifier: $identifier }} -f -e --content-type application/json
http post "http://localhost:8008/_matrix/client/v3/login" { type: "m.login.token", token: $token_request.body.login_token, "initial_device_display_name": "test (token)" } -f -e --content-type application/json |
117fc8f
to
360f5e9
Compare
Pushed a couple fixes, cleaned up code, and use database serialisations/deserialisations instead of the messy manual converting to/from byte slices and ad-hoc identifier parsing code. That stuff was only needed in Conduit where they don't have serialisation or deserialisation for keys/values like we do, hence the whole manual If you can test and see if it all still works that'd be appreciated, though on the surface looks good now. |
Signed-off-by: strawberry <[email protected]>
Tested the new changes, everything works as expected (including token timeouts and non-reuse). Good to know about the serde utilities, that's helpful. |
This is a component of QR login without OIDC. (the other one being the insecure rendezvous endpoint for encryption, also used for OIDC QR login)
It allows existing sessions to generate short-lived tokens which can be used to login a new session. Tokens are automatically deleted on use.
I've added two new config options, one allowing disabling the generation and usage of the tokens and the other setting the length the tokens are valid for (by default two minutes). For some reason, the example config isn't regenerating, though.
Calling the
/login/get_token
endpoint requires UIA. I've not been able to work out how to reject UIA sessions that have been used before (a security feature required by the spec). This might require storing additional state in the database.I've also removed the undocumented
jwt_secret
option and related code - it seems this was a part of a SSO implementation. d49911c