Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make the device id on e2e key upload optional #956

Merged
merged 4 commits into from Jul 27, 2016

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jul 27, 2016

We should now be able to get our device_id from the access_token, so the device_id on the upload request is optional. Where it is supplied, we should check that it matches.

Also make sure that the device_id is registered in the devices table, for both new e2e keys and those already in the database.

Finally, delete e2e keys from the database when we delete a device.

We should now be able to get our device_id from the access_token, so the
device_id on the upload request is optional. Where it is supplied, we should
check that it matches.

For active access_tokens without an associated device_id, we ought to register
the device in the devices table.

Also update the table on upgrade so that all of the existing e2e keys are
associated with real devices.
@richvdh
Copy link
Member Author

richvdh commented Jul 27, 2016

matrixbot: retest this please

@@ -51,23 +54,47 @@ class KeyUploadServlet(RestServlet):
},
}
"""
PATTERNS = client_v2_patterns("/keys/upload/(?P<device_id>[^/]*)", releases=())
PATTERNS = client_v2_patterns("/keys/upload(/(?P<device_id>[^/]+))?$",
releases=(), v2_alpha=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to update sytest to use unstable rather than v2_alpha?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you already have.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to remove the v2_alpha path?

Copy link
Member Author

Choose a reason for hiding this comment

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

just that it's kinda BS, and Vector is using unstable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is Vector the only thing using that API? I though Tor had got a client using the e2e stuff.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah he does. https://github.com/torhve/weechat-matrix-protocol-script/blob/master/matrix.lua

and I see he's using v2_alpha

FUCK IT

this is why we shouldn't publish apis on v2_alpha until they are stable.

@NegativeMjark
Copy link
Contributor

matrixbot: retest this please

if device_id is not None:
# passing the device_id here is deprecated; however, we allow it
# for now for compatibility with older clients. But if a device_id
# was given here and in the auth, they must match.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do they need to match? Do they match in vector now, or will vector need to be updated for this to work?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems to be silly to allow you to upload keys for a different device.

And sadly this does need fixing in vector. I'm trying to fix vector, but that is making me cry too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might it be worth holding off adding this check until vector is updated? Or are we concluding that it's okay to break it on the old vector?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah and it's gonna break Tor's stuff too. argh fuckery I hate my life.

1. Add v2_alpha URL back in, since things seem to be using it.

2. Don't reject the request if the device_id in the upload request fails to
   match that in the access_token.
@NegativeMjark
Copy link
Contributor

LGTM

@richvdh richvdh merged commit 40e5396 into develop Jul 27, 2016
@richvdh richvdh deleted the rav/check_device_id_on_key_upload branch October 7, 2016 15:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants