[Prototype] Add mandatory meta_key
check to server
#937
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites:
dev
branchdev
Summary
This adds a prototype of a basic authentication system to the API server for meta cache computations. Since the meta computations run on a multi-user machine, with read and write privileges to the main DB, we need to make it secure. The idea here is to run the API server with
user1
and run the meta cache computations withuser2
. Both users will share a secret key, which will make sure the API server only responds to requests made byuser2
. The basic logic is to expect a secret meta_key parameter in every request.Many tests had to be fixed. I went with a simple patching route that added the missing fake
meta_key
parameter in most requests.This will likely be deprecated by #633, but the review and roll out of that work is still a way into the future.
Creating this PR for visibility and review, though it definitely should not be merged into
dev
. I envision that this code will continue to live on a separate branch and the meta cache computations server will just run its API server from that branch. Any updates to the JIT computations will need to be propagated to this branch too, whenever they are pushed todev
. The diffs shouldn't be too hard to manage. We should probably automate pulling into this branch whendev
gets updated. We will also want to automate updating the meta cache computations API server whenever this code gets updated.For the sake of tests passing, the
meta_key
comparison only expects ameta_key
if more than zero parameters were requested from the API. So for example, requests likehttps://api.covidcast.cmu.edu/epidata/covidcast/
andhttps://api.covidcast.cmu.edu/epidata/
pass. For these two, the result returns no actual data, so it's fine, but I need to double check that this won't expose information in other endpoints.