From 571a988be9ef62cbaf98a3eac74ec9e79c4595e5 Mon Sep 17 00:00:00 2001 From: "m.lettere" Date: Fri, 22 Oct 2021 12:45:21 +0200 Subject: [PATCH] added more info on token parse error --- roles/pep/templates/pep.js.j2 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/roles/pep/templates/pep.js.j2 b/roles/pep/templates/pep.js.j2 index 60765db..a4a9026 100644 --- a/roles/pep/templates/pep.js.j2 +++ b/roles/pep/templates/pep.js.j2 @@ -129,7 +129,12 @@ function verifyToken(context){ return context.request.subrequest("/jwt_verify_request", options) .then(reply=>{ if (reply.status === 200) { - var response = JSON.parse(reply.responseBody); + var response = null + try{ + response = JSON.parse(reply.responseBody); + } catch(error){ + throw new Error("Unable to parse response json from token request: " + reply.responseBody) + } if (response.active === true) { return response } else { @@ -153,7 +158,12 @@ function requestToken(context){ return context.request.subrequest("/jwt_request", options) .then(reply=>{ if (reply.status === 200) { - var response = JSON.parse(reply.responseBody); + var response = null + try{ + response = JSON.parse(reply.responseBody); + } catch(error){ + throw new Error("Unable to parse response json from token request: " + reply.responseBody) + } context.authn.token = response.access_token context.authn.verified_token = JSON.parse(Buffer.from(context.authn.token.split('.')[1], 'base64url').toString())