Skip to content
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

Do not delete API key to enable rollbacks to previous version. #4105

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion aleph/logic/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def hash_plaintext_api_keys():
for index, partition in enumerate(results.partitions()):
for role in partition:
role.api_key_digest = hash_api_key(role.api_key)
role.api_key = None
db.session.add(role)
log.info(f"Hashing API key: {role}")
log.info(f"Comitting partition {index}")
Expand Down
7 changes: 6 additions & 1 deletion aleph/tests/test_api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ def test_hash_plaintext_api_keys(self):
hash_plaintext_api_keys()

db.session.refresh(user_1)
assert user_1.api_key is None

# Do not delete the plaintext API key to allow for version rollbacks.
# `api_key` column will be removed in the next version at which point all
# plaintext keys will be deleted.
assert user_1.api_key == "1234567890"

assert user_1.api_key_digest == hash_api_key("1234567890")

db.session.refresh(user_2)
Expand Down
Loading