botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Skype fails due to lowercase AppId

Open pietie opened this issue 10 years ago • 7 comments

(using nodejs and v3.1.1) My Skype channel failed with an "invalid token" error. When I dug deeper I saw it was because payload.aud in the verify function call of JWT came through lowercase which does not match the uppercase version I passed to the ChatConnector. If I ignore the case my Skype channel works fine.

Telegram and WebChat come through as uppercase.

Considering that the generated AppId is a GUID I would not expect it to be case-sensitive at all so I would consider this a bug.

On a side note...it would be nice if you could include the more descriptive exceptions from JWT instead of just a generic "invalid token" message

pietie avatar Jul 20 '16 06:07 pietie

Are you sure you're seeing uppercase values from Telegram and WebChat?

We actually don't track this data as a GUID -- we have it stored internally as a string, and it's lowercase for all channels.

dandriscoll avatar Jul 20 '16 14:07 dandriscoll

I just output payload.aud to the console and Telegram and WebChat was uppercase yes. I'll try and do some more traces tomorrow.

So if you always store it as lowercase internally I can pass it to ChatConnector as all caps?

pietie avatar Jul 20 '16 16:07 pietie

That's very strange.

The JWT libraries we rely on do case-sensitive comparisons.

I'm interested to see the raw JWT token where you're seeing the uppercase characters. Not because I don't believe you -- I do :) -- but I can't figure out where it would be coming from, and maybe the token has some clues.

dandriscoll avatar Jul 20 '16 17:07 dandriscoll

var connector = new builder.ChatConnector({
    appId: "UPPERlower",
    appPassword: "********"
});

From the traces below I can now see my appId is compared as-is without every converting the case. Is this not a problem?

I added the following just before the match takes place in verify.js

console.info("options.audience:");
console.dir(options.audience);
console.info("payload.aud:");
console.dir(payload.aud);

var audiences = Array.isArray(options.audience)? options.audience : [options.audience];
var target = Array.isArray(payload.aud) ? payload.aud : [payload.aud];

var match = target.some(function(aud) { return audiences.indexOf(aud) != -1; });

Test button on dashboard


{ header:
   { typ: 'JWT',
     alg: 'RS256',
     kid: 'GCxArXoN8Sqo7PweA7-z65denJQ',
     x5t: 'GCxArXoN8Sqo7PweA7-z65denJQ' },
  payload:
   { iss: 'https://api.botframework.com',
     aud: 'EBDBC4F0-4378-4002-974E-7DF95F9F569D',
     exp: 1469075803,
     nbf: 1469075203 },
  signature: 'tVBDUkIGK527XMDX0WWm723sEOSXIosNafUkd-ggLyVOb2PhUvFCHrschk5oOBhXZWCnNNX8O9W5-0LQM_nH661kyWJZHSizpaeFHQ950ZADUO4uEQ-spzjRjLjL-vCsxPq39FAX
TeZkH_0ZVei6AEorbRjehS6Qm6EhKYMMbeWxqQRGrGXKqNM49EfnKelmJvEBLURebxMqE3Tpid1Lv8eG9bExrRcnp6dQOZNefblwKnUmxObcLajm001evv40eSy7YjCbYS5mUVLhSULLfZeKJQx3ut
ZxNulTRjASyovQJuwZvtYXrTTkHTJCj5rzBYIpZps1R30Q-3c28nTgeg' }

options.audience:
'UPPERlower'
payload.aud:
'EBDBC4F0-4378-4002-974E-7DF95F9F569D'

Skype


{ header:
   { typ: 'JWT',
     alg: 'RS256',
     kid: 'b4ysOWItD13iQfLLeBFX9lRPDtk',
     x5t: 'b4ysOWItD13iQfLLeBFX9lRPDtk' },
  payload:
   { iss: 'https://api.botframework.com',
     aud: 'ebdbc4f0-4378-4002-974e-7df95f9f569d',
     exp: 1469076258,
     nbf: 1469075658 },
  signature: 'QFGy4yEHhiJvuji6L_GoWhYlfCuFGxdRSBMR3zK5sgTo3OHaFOIjdTyUzCLF_lOvBkdZocwYU12Zb9BPVgmYc--PUfI1I3WnaRUTAqmYojMP6j99orIJF6j4tm2cZROD73r_CdIR
DOyBZPJwfEHcDwrOhDA1lYpU8qftdOWFm2qqd8Ra1O038MDjzLqUbONmu--RoC5gromlDJk9q28MPPeHMRcME-PX1LEJUM1FLugPpDDWxPmoLF-wYymjqTep4_uzFW_LMA1QGg5Tq8R05sRz3Y4vA7
rf5MEXnMmyx3eZZa7MTBw-dldiYEoIHzPrakP3Bl1sUuPazSLc_PpX9g' }


options.audience:
'UPPERlower'
payload.aud:
'ebdbc4f0-4378-4002-974e-7df95f9f569d'

Telegram


{ header:
   { typ: 'JWT',
     alg: 'RS256',
     kid: 'GCxArXoN8Sqo7PweA7-z65denJQ',
     x5t: 'GCxArXoN8Sqo7PweA7-z65denJQ' },
  payload:
   { iss: 'https://api.botframework.com',
     aud: 'EBDBC4F0-4378-4002-974E-7DF95F9F569D',
     exp: 1469076704,
     nbf: 1469076104 },
  signature: 'JbuRc86H8Pf3NBuWXrk2yijkswJvtY3aHW6c1B7i1v6j1wTSO8RLtANHJE_cZK7v4UJ1OORrww7Vxewsp8uDes1QbAhege00RNU0MoU471mlowAzk_sV3rgdFqxVJCWgRw0B2z23
ePiohs5IPdSz-wYAjpgt2hpLIZYFC4tQWMnkzznDLgN3mFMdR4f5le2J4KpGi12p4H6zlDVLG4AgYMHaHZuZbDftII0cRjyE47rRH-ZLWPXtrtnR09jwGHZwckjCTqNET9JiLz3IhwjePrIoHzKpM7
3wjsG9nLYs0Xgny64-UEGO94-pMEdGFRKvtblL1bPGc6yDF_hcGS2FOg' }


options.audience:
'UPPERlower'
payload.aud:
'EBDBC4F0-4378-4002-974E-7DF95F9F569D'

pietie avatar Jul 21 '16 04:07 pietie

Yours is literally the only uppercase app ID in the entire system. Did you paste it in from somewhere?

We're going to normalize them in the future so they're all lowercase. I'm happy to update yours so it's lowercase now, if you'd like.

dandriscoll avatar Jul 21 '16 05:07 dandriscoll

I copied it from https://apps.dev.microsoft.com (where it is lowercase) but I battled to register my bot originally so I may have tried a couple of things. :relaxed:

Yes please update mine to lowercase, thanks!

pietie avatar Jul 21 '16 05:07 pietie

Yeah, I think I put together how you got in to this situation. You're the first one to do it but other bot developers may hit it, soon. I'll add something to make the upgrade work smoothly for bots that started with uppercase GUIDs from the Skype portal.

dandriscoll avatar Jul 21 '16 16:07 dandriscoll