Browse Source

FEAT: token util better logging for timeouts, verification

master
Aaron van Meerten 5 years ago
parent
commit
e439d065b7
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      resources/prosody-plugins/token/util.lib.lua

+ 6
- 1
resources/prosody-plugins/token/util.lib.lua View File

152
             -- TODO: This check is racey. Not likely to be a problem, but we should
152
             -- TODO: This check is racey. Not likely to be a problem, but we should
153
             --       still stick a mutex on content / code at some point.
153
             --       still stick a mutex on content / code at some point.
154
             if code == nil then
154
             if code == nil then
155
-                http.destroy_request(request);
155
+                module:log("warn", "Timeout %s seconds fetching public key from: %s",http_timeout,keyurl);
156
+                if http.destroy_request then
157
+                    http.destroy_request(request);
158
+                end
156
                 done();
159
                 done();
157
             end
160
             end
158
         end
161
         end
175
 -- @param 'iss' claim from the token to verify
178
 -- @param 'iss' claim from the token to verify
176
 -- @return nil and error string or true for accepted claim
179
 -- @return nil and error string or true for accepted claim
177
 function Util:verify_issuer(issClaim)
180
 function Util:verify_issuer(issClaim)
181
+    module:log("debug","verify_issuer claim: %s against accepted: %s",issClaim, self.acceptedIssuers);
178
     for i, iss in ipairs(self.acceptedIssuers) do
182
     for i, iss in ipairs(self.acceptedIssuers) do
179
         if issClaim == iss then
183
         if issClaim == iss then
180
             --claim matches an accepted issuer so return success
184
             --claim matches an accepted issuer so return success
189
 -- @param 'aud' claim from the token to verify
193
 -- @param 'aud' claim from the token to verify
190
 -- @return nil and error string or true for accepted claim
194
 -- @return nil and error string or true for accepted claim
191
 function Util:verify_audience(audClaim)
195
 function Util:verify_audience(audClaim)
196
+    module:log("debug","verify_audience claim: %s against accepted: %s",audClaim, self.acceptedAudiences);
192
     for i, aud in ipairs(self.acceptedAudiences) do
197
     for i, aud in ipairs(self.acceptedAudiences) do
193
         if aud == '*' then
198
         if aud == '*' then
194
             --* indicates to accept any audience in the claims so return success
199
             --* indicates to accept any audience in the claims so return success

Loading…
Cancel
Save