Skip to content

Conversation

@vgrozdanic
Copy link
Member

@vgrozdanic vgrozdanic commented Nov 18, 2025

This is an SQL no-op, but the change IS NOT no-op - we will start writing entries in client_secret column in a new format (enc:plaintext:<base64_value>), but still without any problems read old plain text format!

The field and all of the operations on it has already been tested in a sandbox.

Instead of using the basic Django's CharField, we are now moving to EncryptedCharField (inherits CharField) which encrypts/decrypts the value on the fly. This changes nothing in how we use the value in the codebase, since in memory once the object is fetched, the value is decrypted, but while saving it to db, we will no longer save it in plain text.

This is the first of many models that will be migrated to a new encrypted field.

More info about the project can be found here.

The encryption method is controlled via database.encryption.method option, so for now we will still write everything in plain text, and slowly - region by region switch this to Fernet encryption.

EncryptedCharField is implemented here:

class EncryptedCharField(EncryptedField, CharField):

Closes TET-1459: Migrate TempestCredential model

@vgrozdanic vgrozdanic requested a review from a team as a code owner November 18, 2025 14:23
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2025
@vgrozdanic vgrozdanic requested a review from oioki November 18, 2025 14:23
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/tempest/migrations/0003_use_encrypted_char_field.py

for 0003_use_encrypted_char_field in tempest

--
-- Alter field client_secret on tempestcredentials
--
-- (no-op)

@linear
Copy link

linear bot commented Nov 18, 2025

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. The field will continue using plaintext (but with new marker prefixes) for now, and will switch to fernet encryption in the future.

@vgrozdanic vgrozdanic merged commit c983b71 into master Nov 19, 2025
71 of 72 checks passed
@vgrozdanic vgrozdanic deleted the vg/move-tempest-to-encryptedcharfield branch November 19, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants