Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feature: allow channels to register with public key #382

Merged
merged 1 commit into from
Mar 4, 2016

Conversation

jrconlin
Copy link
Member

Channels can include a public key when registering a new subscription
channel. This public key should match the public key used to send
subscription updates later.

NOTE: this patch changes the format of the endpoint URLs, & the content
of the endpoint URL token. This change also requires that ChannelIDs be
normalized to dashed format, (e.g. a lower case, dash delimited string
"deadbeef-0000-0000-deca-fbad11112222") This is the default mechanism
used by Firefox for UUID generation. It is STRONGLY urged that clients
normalize UUIDs used for ChannelIDs and User Agent IDs. While this
should not break existing clients, additional testing may be required.

Closes #326

@bbangert r?

def normalize_id(id):
if not id:
return id
return str(uuid.UUID(id))
Copy link
Member

Choose a reason for hiding this comment

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

This is an expensive operation. Might want to have a regex for the normalized ID, so that re-normalizing a normalized one isn't done, which would be faster if its generally the case that they're already normalized. If it's rare that they're normalized, the extra regex would be slower... so whichever.

@bbangert
Copy link
Member

bbangert commented Mar 2, 2016

Pending a more efficient normalize func, this patch looks great. 👏

return id
if (len(id) == 36 and id[8] == id[13] == id[18] == id[23] == '-'):
return id.lower()
raw = id.lower().replace('-', '')
Copy link
Member

Choose a reason for hiding this comment

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

The - are removed so that they can be added again next?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is more a sanity thing. If there are misplaced dashes, strip them before we do any additional formatting. In reality, I should be stripping non-hex characters and checking for string length, but that gets me back precariously to just running the string through uuid.UUID().

@bbangert
Copy link
Member

bbangert commented Mar 2, 2016

Commit message has a semicolon after Closes that shouldn't be there, it seems to screw up multiple tools parsing the commit messages.

@jrconlin jrconlin force-pushed the feature/jwt_chan branch 2 times, most recently from a2e7e11 to f7bb8ef Compare March 2, 2016 21:23
@ghost
Copy link

ghost commented Mar 2, 2016

This looks really good, @jrconlin! 💯 Are you planning to add key handling to autopush/websocket.py in a follow-up?

@@ -1000,7 +1000,7 @@ def process_register(self, data):
self.transport.pauseProducing()

d = self.deferToThread(self.ap_settings.make_endpoint, self.ps.uaid,
Copy link

Choose a reason for hiding this comment

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

Do you have an integration test for this, by chance? I don't want to block this from landing based on that, but it would be nice to see it end-to-end.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that a change like this should have an integration test.

Channels can include a public key when registering a new subscription
channel. This public key should match the public key used to send
subscription updates later.

NOTE: this patch changes the format of the endpoint URLs, & the content
of the endpoint URL token. This change also requires that ChannelIDs be
normalized to dashed format, (e.g. a lower case, dash delimited string
"deadbeef-0000-0000-deca-fbad11112222") This is the default mechanism
used by Firefox for UUID generation. It is STRONGLY urged that clients
normalize UUIDs used for ChannelIDs and User Agent IDs. While this
should not break existing clients, additional testing may be required.

Closes #326
@bbangert
Copy link
Member

bbangert commented Mar 4, 2016

r+

bbangert added a commit that referenced this pull request Mar 4, 2016
feature: allow channels to register with public key
@bbangert bbangert merged commit 57243be into master Mar 4, 2016
@bbangert bbangert deleted the feature/jwt_chan branch March 4, 2016 00:12
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.

2 participants