Browse Source

Fixes using public key to verify tokens.

j8
damencho 8 years ago
parent
commit
34be638fca
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      resources/prosody-plugins/token/util.lib.lua

+ 5
- 4
resources/prosody-plugins/token/util.lib.lua View File

149
 
149
 
150
 --- Verifies token
150
 --- Verifies token
151
 -- @param token the token to verify
151
 -- @param token the token to verify
152
+-- @param secret the secret to use to verify token
152
 -- @return nil and error or the extracted claims from the token
153
 -- @return nil and error or the extracted claims from the token
153
-function Util:verify_token(token)
154
-    local claims, err = jwt.decode(token, self.appSecret, true);
154
+function Util:verify_token(token, secret)
155
+    local claims, err = jwt.decode(token, secret, true);
155
     if claims == nil then
156
     if claims == nil then
156
         return nil, err;
157
         return nil, err;
157
     end
158
     end
217
     -- now verify the whole token
218
     -- now verify the whole token
218
     local claims, msg;
219
     local claims, msg;
219
     if self.asapKeyServer then
220
     if self.asapKeyServer then
220
-        claims, msg = self:verify_token(session.auth_token);
221
+        claims, msg = self:verify_token(session.auth_token, pubKey);
221
     else
222
     else
222
-        claims, msg = self:verify_token(session.auth_token);
223
+        claims, msg = self:verify_token(session.auth_token, self.appSecret);
223
     end
224
     end
224
     if claims ~= nil then
225
     if claims ~= nil then
225
         -- Binds room name to the session which is later checked on MUC join
226
         -- Binds room name to the session which is later checked on MUC join

Loading…
Cancel
Save