-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added an encryption mechanism for API keys, Fixed the config syncing problem #229
Conversation
Thanks for the clean and clear PR. Tests are not passing due to probably just a need to update the go mods. The error due to which test-go is failing is this:
|
fixed the dependency and go validation problems. the CircleCI pipeline passed successfully. |
Makefile
Outdated
@@ -29,6 +29,7 @@ export [email protected] | |||
export PROXEUS_DATA_DIR?=./data | |||
export PROXEUS_DATABASE_ENGINE?=storm | |||
export PROXEUS_DATABASE_URI?=mongodb://localhost:27017 | |||
export PROXEUS_ENCRYPTION_SECRET_KEY=734yvc2093dbc2vgdi93ljwwncshhd29 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to something like "PleAsE_chAnGe_me_32_Characters++"
to make it clear that this is only a demo key. Also without ?=
it will not get replaced by an environment variable.
We still need to add the new environment variable to documentation, however as tests are passing and this looks now all fine to me, I'm accepting the PR - with many thanks 🎉 |
Pull Request Details
This pull request includes solutions for issues #1 and #175.
Two issues are addressed in this PR.
Issue #175
The configs stored in the settings database and the environment key/values were not always in sync.
The reason is that when the application starts, it does not check or pick the environment variables if the application has been initialized previously.
so, because we have multiple sources of truth and do not check the changes in environment variables, the changes won't affect the code. as a workaround, I added a simple logic to compare the values every time the app starts.
note: the changes to the environment variables won't take effect until the next application restart.
solution: the better approach is to remove the API keys from the settings, and use a hot reload config reader package like Viper.
Issue #1
the keys are stored in the database in plain text.
the solution: I added AES Encryption/Decryption utility for encrypting the keys when storing and decrypting them when reading.
note: we need to add a secret key(PROXEUS_ENCRYPTION_SECRET_KEY = 32 characters long string) to the environment variables for this. so the docs should be updated to let the platform maintainer knows about it.