Skip to content

The logins rename reseals every payload under the new table name - #406

Merged
czpython merged 2 commits into
mainfrom
commonzenpython/provider-logins-reencrypt
Sep 3, 2026
Merged

The logins rename reseals every payload under the new table name#406
czpython merged 2 commits into
mainfrom
commonzenpython/provider-logins-reencrypt

Conversation

@czpython

@czpython czpython commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Bug

e3a9c7d1b5f4 renames harness_logins to provider_logins. ProviderLogin.payload is an EncryptedJsonField, and its AES-GCM AAD is <table>.<column>. Every row written before the rename is sealed under harness_logins.payload; the model now opens with provider_logins.payload, so GCM authentication fails and every pre-existing login raises SecretDecryptError on token refresh and on use. Fresh rows encrypt under the new name, so CI could not see it.

Fix

The migration decrypts each provider_logins.payload under the old AAD and re-encrypts it under the new one, right after the rename. Downgrade does the reverse. Both use druks.secrets.utils, so the same configured keys apply.

Audit of the other provider migrations: a4c8e2f7b913 and c9d1e3f5a7b2 rename nothing that carries an encrypted column. harness_logins.payload is the only encrypted column any migration has renamed.

Verification

Checked by hand against a scratch database: upgrade to the revision before the rename, seed a harness_logins row sealed under the old AAD, upgrade to head, decrypt under the new AAD. Without the reseal step this raises SecretDecryptError; with it the payload reads back. The downgrade reseal was checked the same way.

conftest._OWN_DATABASE_MODULES drops the stale test_harness_login_persistence name for test_provider_login_persistence, which the earlier rename left behind.

docs/development.md notes that renaming a table or column with an encrypted field needs this step.

Gates

  • ruff check / ruff format --check: clean
  • pytest backend/: passed

🤖 Generated with Claude Code

An encrypted column's AAD is "<table>.<column>". e3a9c7d1b5f4 renamed
harness_logins to provider_logins and left every payload sealed under the
old name, so every pre-existing login failed with SecretDecryptError on
refresh and on use. The migration now decrypts each row under the old
name and re-encrypts it under the new one, in both directions.

A migration test seeds a row under harness_logins, runs the upgrade, and
decrypts it under provider_logins. Fresh rows encrypt under the new name,
so the existing suite could not see the break.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mintlify

mintlify Bot commented Sep 3, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
druks 🟢 Ready View Preview Sep 3, 2026, 4:50 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@czpython
czpython enabled auto-merge (squash) September 3, 2026 16:51
@czpython
czpython merged commit 6b350ce into main Sep 3, 2026
3 checks passed
@czpython
czpython deleted the commonzenpython/provider-logins-reencrypt branch September 3, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant