-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api key guard #205
Merged
Merged
Api key guard #205
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…g MC_API_KEY, which should fail.
…PI_KEY=shouldfail; cargo test fails.
Shramp
force-pushed
the
api-key-header
branch
from
February 18, 2022 18:06
1024bc3
to
cbce7b4
Compare
briancorbin
approved these changes
Feb 25, 2022
briancorbin
added a commit
that referenced
this pull request
Mar 4, 2022
* adding max limit to some API endpoints (#248) * Remove unnecessary foreign keys from gift_codes table. (#249) * Update readme installation instructions (#250) * Enable foreign key constraints. Fix transient FK errors when deleting an account. (#251) * Remove foreign key check before running migrations. This allows databases with existing foreign key errors to be fixed by the migrations. (#252) * Fix a bug causing sync to create many tiny chunks. (#253) * Remove target block arg from manually sync account fn (#255) * Initial action to build containers for tag pushes (#256) * Supporting FOG enabled accounts (#254) * FOG Creds default to empty string if not provided from API (#257) * update readme (#259) * Api key guard (#205) * fixing issue with ledger not syncing automatically (#261) * sync up to the last block instead of excluding it (#262)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Increase security on the full-service wallet's jsonrpc loop.
In this PR
Full-service now examines an MC_API_KEY environment variable. If the environment variable is left blank, no checks will be performed. However, if the environment variable is set, an equality check will be performed, looking for an X-API-KEY header in the incoming http request. If these are not equal, an error will be returned. If this header does equal the environment variable, the jsonrpc command will be performed.
The API key sourced from an env var and then added to the Rocket client's state. This allows us to source the API key from places other than the env var without changing the code for the request guard, which is particularly useful in testing. Testing with env vars in Rust is a bit fraught. Env vars are shared across all tests and tests run simultaneously, so you can't scope an env var config to a particular test.
Also did a bit of test util refactoring to help test this functionality
Implements functionality described in Asana ticket "full-service API key"
In addition to unit tests, I ran the following smoke tests: