ably / ably-php

PHP client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
50 stars 10 forks source link

ttl seems to be set to null in a created token request? #46

Open SimonWoolf opened 7 years ago

SimonWoolf commented 7 years ago

https://app.intercom.io/a/apps/ua39m1ld/respond/inbox/all/conversations/10861930672

Not sure if this is a bug in ably-php, ably-js, or somewhere inbetween. Can't really see how it could be any of them, to be honest, there doesn't seem room for anything to go wrong in any of the stages that I can see. But it must be going wrong somewhere.

Customer creating token request in php with

$token = $this->ably->auth->createTokenRequest([
  'ttl' => 86400000,
  'capability'=> [ $channel => $capabilities],
  'clientId' => 'customer-'.$user->getId()
]);

By the time it gets to ably-js, it looks like: {"ttl":null,"capability":"{\"redacted:*\":[\"subscribe\",\"history\"]}","clientId":"customer-38","timestamp":"1500420264269","keyName":"<redacted>","nonce":"6b8c0f7b37bf2d100fa210204f8d80ad","mac":"oAsynffIX9glVWpJcmNlDpgvZx9dMCNF3dctiLk1VGM="}

With the ttl being null. This results in the mac being incorrect, as the ttl was 86400000 at the time the mac was signed -- which I've confirmed by getting the mac to match if I force it to be that manually.

┆Issue is synchronized with this Jira Bug by Unito

SimonWoolf commented 7 years ago

Reply from customer about how he's serializing the token request:

I use symfony so it uses the JMSSerializer Bundle to serialize the json. I created a custom entity as JMSSerializer converts camelCase to underscore case by default so I needed to use a custom entity so that this would not happen

Will follow up on whether it's possible that that might remove the ttl