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