Read CIFS encryption key from environment variable and base64 decode it #79
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.
Overview
This PR implements secure loading of the CIFS encryption key from an environment variable instead of using an empty string hardcoded in the configuration.
Problem
Previously, the CIFS encryption configuration used an empty string for the
publicKeyvalue:This meant the encryption key had to be manually configured or left empty, which is not secure for deployment scenarios.
Solution
The encryption key is now:
CIFS_ENCRYPTION_KEYenvironment variable at runtimepublicKeyKey Features
✅ Secure Runtime Configuration
✅ Robust Error Handling
binascii.Error,UnicodeDecodeError), logs the error, and falls back gracefully✅ Code Consistency
os.environ.get()pattern consistent with other environment variable usage in the codebase (e.g.,CIFS_SERVER,MAIA_PRIVATE_REGISTRY)asciiencoding to match other base64 operations throughout the fileChanges
Modified file:
MAIA/maia_admin.pyimport binasciifor specific exception handlingTesting
Deployment
To use this feature, set the
CIFS_ENCRYPTION_KEYenvironment variable with a base64-encoded encryption key:If the environment variable is not set, the system will log a warning and use an empty string, maintaining backward compatibility.
Related
Fixes the requirement to securely load and decode CIFS encryption keys at runtime for production deployments.
Original prompt
Fixes #78
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
📚 Documentation preview 📚: https://MAIA--79.org.readthedocs.build/en/79/