Repository navigation
fix: derive per-role Postgres passwords from the shared RLS secret - #111
Merged
Merged
Conversation
Role passwords were derived from DATASOURCE_SECRET_KEY, the key that also encrypts stored data source options. Platform derives the same passwords from the shared RLS secret, and on deployments where the two values differ Redash cannot log in as an RLS role. Read the secret from REDASH_RLS_SECRET instead and raise if it is unset, rather than falling back to a key that would derive wrong passwords. DATASOURCE_SECRET_KEY keeps encrypting data source options unchanged. A test pins the derivation to the vector platform's gen_role_pass produces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
Derive per-role Postgres passwords (
PostgreSQL._gen_role_pass) from a newREDASH_RLS_SECRETsetting instead ofDATASOURCE_SECRET_KEY. If it is unset, raise aValueErrornaming the variable rather than falling back to a key that would derive wrong passwords.DATASOURCE_SECRET_KEY(datasource encryption) andREDASH_COOKIE_SECRETare untouched.why
Platform creates RLS roles with passwords derived from the shared RLS secret (
/stacklet/<prefix>/rls/secret). Redash usedDATASOURCE_SECRET_KEY, which can differ from it (it does on the ack deployment), so Redash could not log in as RLS roles.DATASOURCE_SECRET_KEYmust keep its value because it decrypts stored datasource configs, so the RLS secret is a separate input. redash-infra suppliesREDASH_RLS_SECRETfrom the shared secret.testing
New unit tests in
tests/query_runner/test_pg.pypin the derived password to the vector produced by platform'sstacklet.shared.sql.rls.gen_role_pass(rolesso_alice_at_example_com_a1b2c3, secretrls-test-secret), check thatDATASOURCE_SECRET_KEYis ignored, and check that an unset secret raises. All tests in that file pass.docs
None needed.