Compare commits
3 Commits
master
...
getPublicK
Author | SHA1 | Date |
---|---|---|
John Shaver | b524fc789a | |
John Shaver | 4c9e70bd6f | |
John Shaver | 4d7167bee9 |
|
@ -158,6 +158,37 @@ OAUTH3.urls.resourceOwnerPassword = function (directive, opts) {
|
|||
, data: body
|
||||
};
|
||||
};
|
||||
|
||||
// Required sub can be provided in either of two formats.
|
||||
// opts : {sub: (subID)}
|
||||
// opts : {session: { token: sub: (subID)}}
|
||||
OAUTH3.urls.publicKeys = function(directive, opts) {
|
||||
if(!directive) {
|
||||
throw new Error("You must supply directives and opts");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
var sub = opts.sub || opts.session.token.sub;
|
||||
var dir = directive.retrieve_jwk;
|
||||
var url = OAUTH3.url.resolve(directive.api, dir.url)
|
||||
.replace(":sub", sub)
|
||||
.replace("/:kid", "");
|
||||
console.log("DEBUG: public key listing url: ", url);
|
||||
|
||||
var method = opts.method || dir.method || "GET";
|
||||
|
||||
return {
|
||||
method: method
|
||||
, url: url
|
||||
, session: opts.session
|
||||
};
|
||||
};
|
||||
|
||||
OAUTH3.urls.grants = function (directive, opts) {
|
||||
// directive = { issuer, authorization_decision }
|
||||
// opts = { response_type, scopes{ granted, requested, pending, accepted } }
|
||||
|
@ -420,6 +451,24 @@ OAUTH3.authz.scopes = function (providerUri, session, clientParams) {
|
|||
};
|
||||
});
|
||||
};
|
||||
|
||||
// Get all public keys for a sub
|
||||
// Required sub can be provided in either of two formats.
|
||||
// opts : {sub: (subID)}
|
||||
// opts : {session: { token: sub: (subID)}}
|
||||
OAUTH3.authz.publicKeys = function (providerUri, opts) {
|
||||
opts = opts ? opts : {};
|
||||
return OAUTH3.discover(providerUri, {
|
||||
client_id: providerUri
|
||||
, debug: opts.debug
|
||||
}).then(function(directive) {
|
||||
return OAUTH3.request(OAUTH3.urls.publicKeys(directive, opts));
|
||||
}).then(function(result) {
|
||||
//TODO: Do we need to cache these? Right now I don't see this request happening often.
|
||||
return result.data;
|
||||
});
|
||||
};
|
||||
|
||||
OAUTH3.authz.grants = function (providerUri, opts) {
|
||||
return OAUTH3.discover(providerUri, {
|
||||
client_id: providerUri
|
||||
|
|
Loading…
Reference in New Issue