-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(cli): add new migrate-secret-key
command (#240)
#240
Conversation
@@ -612,3 +612,33 @@ def update_workflows_disk_quota() -> None: | |||
for workflow in workflows: | |||
store_workflow_disk_quota(workflow) | |||
timer.count_event() | |||
|
|||
|
|||
def change_key_encrypted_columns(old_key): |
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.
praise: I tested both scenarios (with a without the fix) and it works very nicely 👍
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.
suggestion: One observation about the smoothness of the operation for the site admin. I tested a situtaion when the admin does migrate the Invenio DB, but not the REANA DB, following the change of the secret key. In this case, the user cannot login via the web interface, and sees a nice message saying that something went wrong with the application. That's good. However, when the admin looks into reana-server
logs, the admin only sees a Python traceback regrading SQLAlchemy padding error (see below). Could we catch the exception in the reana-server
in order to provide a better phrased hint to the admin about what is happening?
$ k logs reana-server-568fcf5d48-kqvx2
...
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/orm/loading.py", line 725, in _populate_full
dict_[key] = getter(row)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/sql/type_api.py", line 1278, in process
return process_value(impl_processor(value), dialect)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 479, in process_result_value
value = super().process_result_value(value=value, dialect=dialect)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 424, in process_result_value
decrypted_value = self.engine.decrypt(value)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 123, in decrypt
decrypted = self.padding_engine.unpad(decrypted)
File "/usr/local/lib/python3.8/dist-packages/sqlalchemy_utils/types/encrypted/padding.py", line 44, in unpad
raise InvalidPaddingError()
sqlalchemy_utils.types.encrypted.padding.InvalidPaddingError
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 have pushed a new commit on top of reana-server/towards-release
: reanahub/reana-server@d50c508
chore(maint-0.9): release 0.9.5 (reanahub#219) feat(cli): add new `migrate-secret-key` command (reanahub#240) ci(python): test more Python versions (reanahub#239) ci(actions): pin setuptools 70 (reanahub#239) Note: The merge commit removes the changes related to pinning `setuptools` to version 70, because this was only necessary for the `maint-0.9` branches, as well as other 0.9.4 release-related changes.
chore(maint-0.9): release 0.9.5 (reanahub#219) feat(cli): add new `migrate-secret-key` command (reanahub#240) ci(python): test more Python versions (reanahub#239) ci(actions): pin setuptools 70 (reanahub#239) Note: The merge commit removes the changes related to pinning `setuptools` to version 70, because this was only necessary for the `maint-0.9` branches, as well as other 0.9.4 release-related changes.
chore(maint-0.9): release 0.9.5 (reanahub#219) feat(cli): add new `migrate-secret-key` command (reanahub#240) ci(python): test more Python versions (reanahub#239) ci(actions): pin setuptools 70 (reanahub#239) Note: The merge commit removes the changes related to pinning `setuptools` to version 70, because this was only necessary for the `maint-0.9` branches, as well as other 0.9.4 release-related changes.
Closes reanahub/reana-server#695
How to test:
invenio instance migrate-secret-key --old-key CHANGE_ME
kubectl rollout restart deployment reana-server
kubectl rollout restart deployment reana-workflow-controller
invenio instance migrate-secret-key --old-key <old_key>
andreana-db migrate-secret-key --old-key <old_key>
(if you didn't set a secret key in (1) and (3), then the old secret key issecret_key
)