-
Notifications
You must be signed in to change notification settings - Fork 6
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
secret management #104
secret management #104
Conversation
maap/Secrets.py
Outdated
headers=self._api_header | ||
) | ||
|
||
return json.loads(response.text) |
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.
I think this should just return a value and not a dict.
Returning a dict object can complicate users code using maag.py
For eg.
token = maap.Secrets().get_secret("name").get("name")
vs if we return just the value it could look like
token = maap.Secrets().get_secret("name")
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.
Updated to support this.
|
||
def add_secret(self, secret_name=None, secret_value=None): | ||
""" | ||
Adds a secret. Secret name must be provided. Secret value may be null. |
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.
What is the use-case of having a secret without a value ?
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.
Mostly because an empty string is a valid value and I don't see a good reason placing additional constraints on this. I was also thinking of cases where users might need to have the secret parameter exist but not necessarily care about the value itself.
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.
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.
Saw this later, commented below.
maap/config_reader.py
Outdated
@@ -81,6 +81,7 @@ def __init__(self, maap_host): | |||
self.algorithm_build = self._get_api_endpoint("algorithm_build") | |||
self.mas_algo = self._get_api_endpoint("mas_algo") | |||
self.dps_job = self._get_api_endpoint("dps_job") | |||
self.member_secrets = self._get_api_endpoint("member_secrets") |
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.
Has this new config also been added to the maap_api_settings file as default config ? here https://github.com/MAAP-Project/maap-api-nasa/blob/main/api/settings.py#L119-L132
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.
I went with the existing member endpoint.
from maap.utils import requests_utils | ||
|
||
|
||
class Secrets: |
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.
Could you add a section in the functional test to test adding, retrieving and deleting a secret?
https://github.com/MAAP-Project/maap-py/blob/master/test/functional_test.py
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.
Yeah, this is next on my to-do.
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.
Implemented.
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.
Looks good. Are we allowing empty secret values then? I'll need to update the API if so: https://github.com/MAAP-Project/maap-api-nasa/blob/develop/api/endpoints/members.py#L457-L459
I think we should allow empty strings for secret values, but not None. I just pushed a commit to ensure the secret_value is not None. |
Can you provide an example where this would be used ? I dont think we should allow empty strings either, unless we have a good reason. Edited |
The good reason I see is that an empty string is a valid string so we shouldn't arbitrarily not allow that. But if that doesn't sway you, I'm fine updating the code to not allow empty strings as values. |
At present, since I do not see a convincing use for an empty string as a secret it does not sway me. Maybe in the future this need might arise. I agree that an empty string is a valid string, but for secrets to me it implies an error on the user/systems part of not providing a valid (length > 0) value. We do not want to promote our secrets database being used as a boolean/parameter flag store. |
headers=self._api_header | ||
) | ||
logger.debug(response.text) | ||
return json.loads(response.text) |
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.
Should this be of type list or dict to match the doc string?
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.
It's a list of dicts. I've updated the doc string to provide an example.
maap/Secrets.py
Outdated
response = response.json() | ||
return response["secret_value"] | ||
|
||
logger.debug(response.text) |
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.
logger.debug(response.text) |
We should not be logging secrets anywhere.
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.
This is logging the api response and not the secret value.
maap/Secrets.py
Outdated
url = self._members_endpoint, | ||
headers=self._api_header | ||
) | ||
logger.debug(response.text) |
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.
logger.debug(response.text) | |
Returns: | ||
list: Secret names for a given user. | ||
""" | ||
try: |
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.
try: | |
try: | |
logger.debug("Fetching all secrets") |
Just more informative to log what function is being called than just logging response.text
.
* Remove the need to track maap.cfg file (#93) * Remove the need to track maap.cfg * Fix merge issues * Allow overriding of MAAP_API_HOST * Split config url construction into functions * Add test for config reader * Add script to perform functional test of maap-py * Construct api root url from provided maap host * Apply suggestions from code review Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Apply suggestions from code review to update url handling Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Remove unused code and memoize get config function * Update request utils to drop class and use methods * Use new request utils and pass maap config object * Update imports and url handling * Simplify boolean self-signed for request utils * Remove usage of os.path.join for constructing urls * Fix variable name in exception message * Remove incorrect import * Update functional tests --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added pagination to listJobs endpoint * change request * Issues/95: Add CICD pipeline (#101) * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Fetch full repo in checkout for sonar analysis * tweak pr template wording * /version 4.0.1a0 * /version 4.1.0a1 * added more query params (#98) * added more query params * added get_job_details flag * cleanup * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added docstring | updated param handling * review updates * review updates * renamed file --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * /version 4.1.0a2 * secret management (#104) * wip * cleanup * updated get_secret endpoint to return value * added tests for secrets management * updated error handling | added logging * review comments * /version 4.1.0a3 * /version 4.2.0a0 * added changelog entry * /version 4.1.0rc1 --------- Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com>
* Release/4.1.0 (#106) * Remove the need to track maap.cfg file (#93) * Remove the need to track maap.cfg * Fix merge issues * Allow overriding of MAAP_API_HOST * Split config url construction into functions * Add test for config reader * Add script to perform functional test of maap-py * Construct api root url from provided maap host * Apply suggestions from code review Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Apply suggestions from code review to update url handling Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Remove unused code and memoize get config function * Update request utils to drop class and use methods * Use new request utils and pass maap config object * Update imports and url handling * Simplify boolean self-signed for request utils * Remove usage of os.path.join for constructing urls * Fix variable name in exception message * Remove incorrect import * Update functional tests --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added pagination to listJobs endpoint * change request * Issues/95: Add CICD pipeline (#101) * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Fetch full repo in checkout for sonar analysis * tweak pr template wording * /version 4.0.1a0 * /version 4.1.0a1 * added more query params (#98) * added more query params * added get_job_details flag * cleanup * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added docstring | updated param handling * review updates * review updates * renamed file --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * /version 4.1.0a2 * secret management (#104) * wip * cleanup * updated get_secret endpoint to return value * added tests for secrets management * updated error handling | added logging * review comments * /version 4.1.0a3 * /version 4.2.0a0 * added changelog entry * /version 4.1.0rc1 --------- Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com> * /version 4.1.0 --------- Co-authored-by: Marjorie Lucas <47004511+marjo-luc@users.noreply.github.com> Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com>
* Release/4.1.0 (#106) * Remove the need to track maap.cfg file (#93) * Remove the need to track maap.cfg * Fix merge issues * Allow overriding of MAAP_API_HOST * Split config url construction into functions * Add test for config reader * Add script to perform functional test of maap-py * Construct api root url from provided maap host * Apply suggestions from code review Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Apply suggestions from code review to update url handling Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Remove unused code and memoize get config function * Update request utils to drop class and use methods * Use new request utils and pass maap config object * Update imports and url handling * Simplify boolean self-signed for request utils * Remove usage of os.path.join for constructing urls * Fix variable name in exception message * Remove incorrect import * Update functional tests --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added pagination to listJobs endpoint * change request * Issues/95: Add CICD pipeline (#101) * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Fetch full repo in checkout for sonar analysis * tweak pr template wording * /version 4.0.1a0 * /version 4.1.0a1 * added more query params (#98) * added more query params * added get_job_details flag * cleanup * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added docstring | updated param handling * review updates * review updates * renamed file --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * /version 4.1.0a2 * secret management (#104) * wip * cleanup * updated get_secret endpoint to return value * added tests for secrets management * updated error handling | added logging * review comments * /version 4.1.0a3 * /version 4.2.0a0 * added changelog entry * /version 4.1.0rc1 --------- Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com> * /version 4.1.0 --------- Co-authored-by: Marjorie Lucas <47004511+marjo-luc@users.noreply.github.com> Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com>
rebased develop onto master and tweaked versions rebased develop onto master and tweaked versions Resolve conflicts (#112) * Release/4.1.0 (#106) * Remove the need to track maap.cfg file (#93) * Remove the need to track maap.cfg * Fix merge issues * Allow overriding of MAAP_API_HOST * Split config url construction into functions * Add test for config reader * Add script to perform functional test of maap-py * Construct api root url from provided maap host * Apply suggestions from code review Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Apply suggestions from code review to update url handling Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Remove unused code and memoize get config function * Update request utils to drop class and use methods * Use new request utils and pass maap config object * Update imports and url handling * Simplify boolean self-signed for request utils * Remove usage of os.path.join for constructing urls * Fix variable name in exception message * Remove incorrect import * Update functional tests --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added pagination to listJobs endpoint * change request * Issues/95: Add CICD pipeline (#101) * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Fetch full repo in checkout for sonar analysis * tweak pr template wording * /version 4.0.1a0 * /version 4.1.0a1 * added more query params (#98) * added more query params * added get_job_details flag * cleanup * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added docstring | updated param handling * review updates * review updates * renamed file --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * /version 4.1.0a2 * secret management (#104) * wip * cleanup * updated get_secret endpoint to return value * added tests for secrets management * updated error handling | added logging * review comments * /version 4.1.0a3 * /version 4.2.0a0 * added changelog entry * /version 4.1.0rc1 --------- Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com> * /version 4.1.0 --------- Co-authored-by: Marjorie Lucas <47004511+marjo-luc@users.noreply.github.com> Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com> Resolve conflicts (#111) * Release/4.1.0 (#106) * Remove the need to track maap.cfg file (#93) * Remove the need to track maap.cfg * Fix merge issues * Allow overriding of MAAP_API_HOST * Split config url construction into functions * Add test for config reader * Add script to perform functional test of maap-py * Construct api root url from provided maap host * Apply suggestions from code review Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Apply suggestions from code review to update url handling Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Remove unused code and memoize get config function * Update request utils to drop class and use methods * Use new request utils and pass maap config object * Update imports and url handling * Simplify boolean self-signed for request utils * Remove usage of os.path.join for constructing urls * Fix variable name in exception message * Remove incorrect import * Update functional tests --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added pagination to listJobs endpoint * change request * Issues/95: Add CICD pipeline (#101) * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Setup CICD * Fetch full repo in checkout for sonar analysis * tweak pr template wording * /version 4.0.1a0 * /version 4.1.0a1 * added more query params (#98) * added more query params * added get_job_details flag * cleanup * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * Update maap/maap.py Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * added docstring | updated param handling * review updates * review updates * renamed file --------- Co-authored-by: Chuck Daniels <chuck@developmentseed.org> * /version 4.1.0a2 * secret management (#104) * wip * cleanup * updated get_secret endpoint to return value * added tests for secrets management * updated error handling | added logging * review comments * /version 4.1.0a3 * /version 4.2.0a0 * added changelog entry * /version 4.1.0rc1 --------- Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com> * /version 4.1.0 --------- Co-authored-by: Marjorie Lucas <47004511+marjo-luc@users.noreply.github.com> Co-authored-by: Sujen Shah <sujen1412@users.noreply.github.com> Co-authored-by: Chuck Daniels <chuck@developmentseed.org> Co-authored-by: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Co-authored-by: frankinspace <frankinspace@users.noreply.github.com> Co-authored-by: marjo-luc <marjo-luc@users.noreply.github.com>
Added maap-py support for user secrets management. Users can now use the following four endpoints to get, add, and delete secrets:
Closes #102 & 1048