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

Migrate secret keys from GPG to database-backed storage #6972

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Oct 5, 2023

Status

Ready for review

Description of Changes

For the final part of the GPG->Sequoia migration, we export sources' secret keys out of GPG and into database-backed storage for use with Sequoia/redwood functions. Because we don't have access to a source's GPG passphrase, we can only do this migration when they log in.

If everything has been successfully migrated, then we delete the GPG key out of the keyring as well.

Tests have been added that cover the pre-existing keypair generation code and the new secret key migration.

Fixes #6802.

Testing

  • Start the dev server (make dev) and open a shell into the container, e.g. podman exec --user=root -it $(podman ps --filter name=securedrop --format '{{.ID}}') bash
  • Run alembic stamp 811334d7105f (ID of the migration before public key one added in Migrate public keys from GPG to database-backed storage #6946)
  • Run ./loaddata.py --gpg to add some GPG sources
  • Run alembic upgrade head, completes successfully. Then run a query like select filesystem_id, pgp_fingerprint, pgp_public_key, pgp_secret_key from sources; to verify we now have sources that have fingerprint + public key in the database, but not secret key
  • Pick one of the GPG-added sources and log in as it.
  • Re-run the database query to see that the secret key is now populated in the database.
  • Obligatory visual review + CI passes

Deployment

Any special considerations for deployment? Not really.

Checklist

  • Linting (make lint) and tests (make test) pass in the development container

For the final part of the GPG->Sequoia migration, we export sources'
secret keys out of GPG and into database-backed storage for use with
Sequoia/redwood functions. Because we don't have access to a source's
GPG passphrase, we can only do this migration when they log in.

If everything has been successfully migrated, then we delete the GPG key
out of the keyring as well.

Tests have been added that cover the pre-existing keypair generation
code and the new secret key migration.

Fixes #6802.
@legoktm legoktm requested a review from a team as a code owner October 5, 2023 03:00
@zenmonkeykstop zenmonkeykstop self-assigned this Oct 5, 2023
@zenmonkeykstop
Copy link
Contributor

zenmonkeykstop commented Oct 6, 2023

(Noting that I had to add the app code directory to PYTHONPATH to get an initial alembic history command to run, as pretty-bad-protocol isn't available otherwise.)

@zenmonkeykstop
Copy link
Contributor

zenmonkeykstop commented Oct 6, 2023

Basic functionality confirmed as per test plan! Given the impact of the change trying it out in a staging/prod env is probably also warranted, tho that can happen once all the sequoia changes are in place and we can try out stuff like upgrade/migration paths.

Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a comment

Choose a reason for hiding this comment

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

LGTM

@zenmonkeykstop zenmonkeykstop merged commit d431061 into develop Oct 6, 2023
@legoktm legoktm deleted the sequoia-migrate-secret branch January 9, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

On-demand migration of sources' private keys to database-backed storage upon login
2 participants