From 34be638fca11fd175cec50523960e13ca3ea04bb Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 25 May 2017 16:45:08 -0500 Subject: [PATCH] Fixes using public key to verify tokens. --- resources/prosody-plugins/token/util.lib.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/prosody-plugins/token/util.lib.lua b/resources/prosody-plugins/token/util.lib.lua index a726d401c..a486a43e3 100644 --- a/resources/prosody-plugins/token/util.lib.lua +++ b/resources/prosody-plugins/token/util.lib.lua @@ -149,9 +149,10 @@ end --- Verifies token -- @param token the token to verify +-- @param secret the secret to use to verify token -- @return nil and error or the extracted claims from the token -function Util:verify_token(token) - local claims, err = jwt.decode(token, self.appSecret, true); +function Util:verify_token(token, secret) + local claims, err = jwt.decode(token, secret, true); if claims == nil then return nil, err; end @@ -217,9 +218,9 @@ function Util:process_and_verify_token(session) -- now verify the whole token local claims, msg; if self.asapKeyServer then - claims, msg = self:verify_token(session.auth_token); + claims, msg = self:verify_token(session.auth_token, pubKey); else - claims, msg = self:verify_token(session.auth_token); + claims, msg = self:verify_token(session.auth_token, self.appSecret); end if claims ~= nil then -- Binds room name to the session which is later checked on MUC join