浏览代码

Fixes using public key to verify tokens.

j8
damencho 8 年前
父节点
当前提交
34be638fca
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5
    4
      resources/prosody-plugins/token/util.lib.lua

+ 5
- 4
resources/prosody-plugins/token/util.lib.lua 查看文件

@@ -149,9 +149,10 @@ end
149 149
 
150 150
 --- Verifies token
151 151
 -- @param token the token to verify
152
+-- @param secret the secret to use to verify token
152 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 156
     if claims == nil then
156 157
         return nil, err;
157 158
     end
@@ -217,9 +218,9 @@ function Util:process_and_verify_token(session)
217 218
     -- now verify the whole token
218 219
     local claims, msg;
219 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 222
     else
222
-        claims, msg = self:verify_token(session.auth_token);
223
+        claims, msg = self:verify_token(session.auth_token, self.appSecret);
223 224
     end
224 225
     if claims ~= nil then
225 226
         -- Binds room name to the session which is later checked on MUC join

正在加载...
取消
保存