Skip to content

Commit

Permalink
Updated frame.context to use req.api_key_id (#9965)
Browse files Browse the repository at this point in the history
* Added api_key_id to frame.context

refs #9865

This is to allow controllers to check permissions using api_key_id data.

* Removed client and client_id from frame.context

refs #9865

This is unused as we only support oauth on v0.1 API.
  • Loading branch information
allouis authored Oct 9, 2018
1 parent 23e9a02 commit 1b9aa25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions core/server/api/shared/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ const http = (apiImpl) => {
params: req.params,
user: req.user,
context: {
user: ((req.user && req.user.id) || (req.user && models.User.isExternalUser(req.user.id))) ? req.user.id : null,
client: (req.client && req.client.slug) ? req.client.slug : null,
client_id: (req.client && req.client.id) ? req.client.id : null
api_key_id: (req.api_key && req.api_key.id) ? req.api_key.id : null,
user: ((req.user && req.user.id) || (req.user && models.User.isExternalUser(req.user.id))) ? req.user.id : null
}
});

Expand Down
5 changes: 2 additions & 3 deletions core/test/unit/api/shared/http_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ describe('Unit: api/shared/http', function () {
apiImpl.args[0][0].data.should.eql({a: 'a'});
apiImpl.args[0][0].options.should.eql({
context: {
user: null,
client: null,
client_id: null
api_key_id: null,
user: null
}
});
});
Expand Down

0 comments on commit 1b9aa25

Please sign in to comment.