diff --git a/README.md b/README.md index bd0b68a..76101ed 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ public keys associated with the correct user when retrieving JWKs. * **Body Params** * `sub`: The [subject](#subject) using `azp` from the url * `scope`: A comma separated list of the permissions granted + * **Response**: The same object returned when retrieving single grants ### Retrieving Grants ### * **URL** `:scheme//:hostname/api/issuer@oauth3.org/grants/:sub/:azp` @@ -121,6 +122,7 @@ public keys associated with the correct user when retrieving JWKs. * **Response** * `sub`: The same `sub` from the url * `azp`: The same `azp` from the url + * `azpSub`: The `sub` for the `azp` * `scope`: A comma separated list of the permissions granted * `updatedAt`: The ms timestamp for the most recent change to the grants diff --git a/grants.js b/grants.js index bd22eb6..dec2d1d 100644 --- a/grants.js +++ b/grants.js @@ -10,7 +10,7 @@ function trim(grant) { return { sub: grant.sub, azp: grant.azp, - // azpSub: grant.azpSub, + azpSub: grant.azpSub, scope: grant.scope, updatedAt: parseInt(grant.updatedAt, 10), }; @@ -74,7 +74,12 @@ function create(app) { }; return req.Store.upsert(grant.sub+'/'+grant.azp, grant); }).then(function () { - return {success: true}; + return req.Store.get(req.params.sub+'/'+req.params.azp); + }).then(function (grant) { + if (!grant) { + throw new Error('failed to retrieve grants after saving them'); + } + return trim(grant); }); app.handlePromise(req, res, promise, '[issuer@oauth3.org] save grants');