-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Scope transaction IDs to the (user, device_id) instead of the access token #1133
Comments
this is arguably an MSC-needing thing or a spec bug. The refresh tokens MSC should have handled it at the time, but that ship has well sailed. |
@matrix-org/spec-core-team thoughts on JFDI and fixing the spec versus requiring an MSC? |
My thoughts:
|
Currently, the spec says that a
though IIRC Synapse currently doesn't follow that. But even with that, it's not clear that I agree that changing it from "access token" to "sequence of access tokens/refresh tokens" should be fine, if someone can think of a better way to word it. Maybe we need to define a "session" (or some term that we haven't already overloaded)? "client session"? |
Am I wrong to think this seems like quite an improbable edge case for me? I guess it depends how clients generate their txnIDs, but for example, Element Web uses a mix of a timestamp + monotonically increasing counter, I don't see how it could ever happen.
My problem with that is it makes it much more difficult to implement, especially in the context of the OIDC work. I recently touched on that part of the code in Synapse, and introducing this kind of 'session' mechanism would require quite a big database migration, adding a unique session ID to existing access/refresh tokens. With the OIDC work, it would add additional requirements on the OP (auth server) which would make it hard for us to use other off-the-shelf OPs like Keycloak. |
It's worth noting that to-device message delivery in |
Could we say that transaction IDs are scoped to a "device" and then define a device as a sequence of access tokens? |
That would complexify by a lot the eventual transition to OIDC, by adding a new concept to keep track of between the HS and the OP. I understand how it would 'fix' the current spec without breaking anything, but I'm also pretty confident that the breakage would be pretty minor in real world cases if we choose to scope the TXN IDs to device_ids. |
Spec-wise, this seems to be fixed by a "session" concept given the MSC's behaviour, though implementation complexity is a whole other note to worry about. To fix the implementation I think we'd need another MSC - it's just not as easy to make the leap towards that with the current understanding. |
This adds two tests, which check the current spec behaviour of transaction IDs, which are that they are scoped to a series of access tokens, and not the device ID. The first test highlight this behaviour, by logging in with refresh token enabled, sending an event, using the refresh token and syncing with the new access token. On the sync, the transaction ID should be there, but currently in Synapse it is not. The second test highlight that the transaction ID is not scoped to the device ID, by logging in twice with the same device ID, sending an event with the first access token, and syncing with the second access token. In that case, the sync should not contain the transaction ID, but I think it's the case in HS implementations which use the device ID to scope the transaction IDs, like Conduit. Related: matrix-org/matrix-spec#1133, matrix-org/matrix-spec#1236, matrix-org/synapse#13064 and matrix-org/synapse#13083
This adds two tests, which check the current spec behaviour of transaction IDs, which are that they are scoped to a series of access tokens, and not the device ID. The first test highlight this behaviour, by logging in with refresh token enabled, sending an event, using the refresh token and syncing with the new access token. On the sync, the transaction ID should be there, but currently in Synapse it is not. The second test highlight that the transaction ID is not scoped to the device ID, by logging in twice with the same device ID, sending an event with the first access token, and syncing with the second access token. In that case, the sync should not contain the transaction ID, but I think it's the case in HS implementations which use the device ID to scope the transaction IDs, like Conduit. Related: matrix-org/matrix-spec#1133, matrix-org/matrix-spec#1236, matrix-org/synapse#13064 and matrix-org/synapse#13083
This adds two tests, which check the current spec behaviour of transaction IDs, which are that they are scoped to a series of access tokens, and not the device ID. The first test highlight this behaviour, by logging in with refresh token enabled, sending an event, using the refresh token and syncing with the new access token. On the sync, the transaction ID should be there, but currently in Synapse it is not. The second test highlight that the transaction ID is not scoped to the device ID, by logging in twice with the same device ID, sending an event with the first access token, and syncing with the second access token. In that case, the sync should not contain the transaction ID, but I think it's the case in HS implementations which use the device ID to scope the transaction IDs, like Conduit. Related: matrix-org/matrix-spec#1133, matrix-org/matrix-spec#1236, matrix-org/synapse#13064 and matrix-org/synapse#13083
This adds two tests, which check the current spec behaviour of transaction IDs, which are that they are scoped to a series of access tokens, and not the device ID. The first test highlight this behaviour, by logging in with refresh token enabled, sending an event, using the refresh token and syncing with the new access token. On the sync, the transaction ID should be there, but currently in Synapse it is not. The second test highlight that the transaction ID is not scoped to the device ID, by logging in twice with the same device ID, sending an event with the first access token, and syncing with the second access token. In that case, the sync should not contain the transaction ID, but I think it's the case in HS implementations which use the device ID to scope the transaction IDs, like Conduit. Related: matrix-org/matrix-spec#1133, matrix-org/matrix-spec#1236, matrix-org/synapse#13064 and matrix-org/synapse#13083
This adds two tests, which check the current spec behaviour of transaction IDs, which are that they are scoped to a series of access tokens, and not the device ID. The first test highlight this behaviour, by logging in with refresh token enabled, sending an event, using the refresh token and syncing with the new access token. On the sync, the transaction ID should be there, but currently in Synapse it is not. The second test highlight that the transaction ID is not scoped to the device ID, by logging in twice with the same device ID, sending an event with the first access token, and syncing with the second access token. In that case, the sync should not contain the transaction ID, but I think it's the case in HS implementations which use the device ID to scope the transaction IDs, like Conduit. Related: matrix-org/matrix-spec#1133, matrix-org/matrix-spec#1236, matrix-org/synapse#13064 and matrix-org/synapse#13083
Transaction IDs are currently scoped by access token. They are used to make some request idempotent, and to help client map sent event when they get back in
/sync
.Problem is, since MSC2918 (aka. refresh tokens), a client may refresh its access token, which may lead to scenarios like this:
/sync
with an access token T1/rooms/{room}/send/{type}/{txnId}
with the access token T2/sync
gets back with the newly created event, but without thetransaction_id
field, since that/sync
was done with another access tokenwhich directly contradicts the spec, where says on the
transaction_id
field:There are other places in the spec where we mention those transaction IDs:
And on the
txnId
on/send
:What I suggest is to use the
device_id
(+user_id
) instead of the access token to scope those transaction IDs.Related Synapse issue: matrix-org/synapse#13064 and PR: matrix-org/synapse#13083
The text was updated successfully, but these errors were encountered: