tweaked what's returned for grant requests

This commit is contained in:
tigerbot 2017-08-01 14:23:43 -06:00
parent c0ad5f19fc
commit ddf461a054
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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');