From 4c9e70bd6f4ff03254420e7174d60e93969e6652 Mon Sep 17 00:00:00 2001 From: John Shaver Date: Fri, 17 Nov 2017 11:57:09 -0800 Subject: [PATCH] Added directive support to getPublicKeys url function. --- oauth3.issuer.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/oauth3.issuer.js b/oauth3.issuer.js index 4b9fcd6..374706f 100644 --- a/oauth3.issuer.js +++ b/oauth3.issuer.js @@ -166,21 +166,19 @@ OAUTH3.urls.publicKeys = function(directive, opts) { if(!directive) { throw new Error("You must supply directives and opts"); } - if(!directive.JWKs) { - //throw new Error("Provider does not support listing public keys."); + if(!directive.retrieve_jwk) { + throw new Error("Provider does not support retreiving public keys."); } if(!opts || (!opts.session && !opts.sub)) { throw new Error("You must supply options.session or a options.sub"); } - //TODO: - //TODO: get the proper directive once it's created!! - //TODO: Do we need to have sub strictly provided? - var sub = opts.sub || opts.session.token.sub - var hardCodedDir = "/api/issuer@oauth3.org/jwks/all/:sub"; - var url = OAUTH3.url.resolve(directive.api, hardCodedDir) - url = url.replace(":sub", sub); - var method = opts.method || "GET"; + var sub = opts.sub || opts.session.token.sub; + var dir = directive.retieve_jwk; + var url = OAUTH3.url.resolve(directive.api, dir.url) + .replace(":sub", sub); + + var method = opts.method || dir.method || "GET"; return { method: method