From fd04d97828ea42b8082f7fd5c02b6e1a60f53f9b Mon Sep 17 00:00:00 2001
From: Zachary Carter <zack.carter@gmail.com>
Date: Tue, 24 Jul 2012 16:40:59 -0700
Subject: [PATCH] Log additional verifier assertion errors, where assertion or
 audience could not be found

---
 bin/verifier | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/bin/verifier b/bin/verifier
index b891002b1..0999750fb 100755
--- a/bin/verifier
+++ b/bin/verifier
@@ -81,14 +81,27 @@ function doVerification(req, resp, next) {
   if (!(assertion && audience)) {
     // why couldn't we extract these guys?  Is it because the request parameters weren't encoded as we expect? GH-643
     const want_ct = [ 'application/x-www-form-urlencoded', 'application/json' ];
+    var reason;
     try {
       var ct = req.headers['content-type'];
       if (ct.indexOf(';') != -1) ct = ct.substr(0, ct.indexOf(';'));
       if (want_ct.indexOf(ct) == -1) throw "wrong content type";
     } catch (e) {
-      return resp.json({ status: "failure", reason: "Content-Type expected to be one of: " + want_ct.join(", ") }, 415);
+      reason = "Content-Type expected to be one of: " + want_ct.join(", ");
+      metrics.report('verify', {
+        result: 'failure',
+        reason: reason,
+        rp: audience
+      });
+      return resp.json({ status: "failure", reason: reason}, 415);
     }
-    return resp.json({ status: "failure", reason: "need assertion and audience"}, 400);
+    reason = "need assertion and audience";
+    metrics.report('verify', {
+      result: 'failure',
+      reason: reason,
+      rp: audience
+    });
+    return resp.json({ status: "failure", reason: reason}, 400);
   }
 
   var startTime = new Date();
-- 
GitLab