Skip to content

feat: add HashedPassword transformer - #482

Open
YauhenBichel wants to merge 1 commit into
GreenmaskIO:mainfrom
YauhenBichel:feat/hashed-password-transformer
Open

YauhenBichel wants to merge 1 commit into
GreenmaskIO:mainfrom
YauhenBichel:feat/hashed-password-transformer

Conversation

@YauhenBichel

@YauhenBichel YauhenBichel commented Sep 11, 2026

Copy link
Copy Markdown

Closes #480

What

A new HashedPassword transformer. It writes a bcrypt hash of one known password into a column, so test accounts can log in after the restore.

  • bcrypt_variant: 2a (default), 2b or 2y. pgcrypto crypt() understands only 2a.
  • cost: 4 to 31, default 10.
  • per_row_salt: default false, so the password is hashed once and the dump stays fast.
  • keep_null: default true.
  • The password comes from the existing resolve_env + ${VAR} feature, so it stays out of the config. Warnings never include it.

Tests

  • Unit tests: variants, NULL handling, salt modes, env var, and validation. All unit tests pass, and golangci-lint v2.10.1 reports 0 issues.
  • End to end on PostgreSQL 17.11: a real dump and restore of 1,051 rows.
    • crypt(pw, hash) = hash is true for all rows.
    • NULL stays NULL, and the old passwords no longer work.
    • The password is not in any dump file.
    • Without the env var, the dump refuses to run.
    • With 2b/2y, pgcrypto gives no error, but every login check is false. This is why the default is 2a.

Written with help from an AI assistant; I reviewed and tested it.

Replace a password hash with a bcrypt hash of one known password, so
test accounts can log in after the restore. The bcrypt_variant
parameter picks the prefix (2a, 2b, 2y); the default 2a is the only one
pgcrypto crypt() understands.

Closes GreenmaskIO#480

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Hashed test passwords that still log in (bcrypt, with pgcrypto's $2a$ prefix)

1 participant