-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
This is identical to #469 with the 2 differences:
- I don't create a settings profile, everything is managed on the role level
- The setting name is different from a bare
readonly- The role is altered so that the setting is
CHANGEABLE_IN_READONLY
- The role is altered so that the setting is
Steps to reproduce
- Create a dummy dataset
CREATE database test_db;
CREATE TABLE test_db.table (a String) ORDER BY tuple();
INSERT INTO test_db.table (a) VALUES ('test');- Create a role and allow changing a setting in readonly mode
CREATE ROLE IF NOT EXISTS my_readonly_role;
ALTER ROLE my_readonly_role SETTINGS SQL_RO_my_rls_key CHANGEABLE_IN_READONLY;
GRANT SELECT on test_db.table TO my_readonly_role;
CREATE ROW POLICY my_table_readonly_policy ON test_db.table USING a = getSetting('SQL_RO_my_rls_key') TO my_readonly_role;- Create a readonly user defaulted to this role
CREATE user my_readonly_user IDENTIFIED WITH sha256_password by 'Str0ngP@ssw0rd' DEFAULT ROLE my_readonly_role SETTINGS readonly = 1;- Appending the setting directly to a query works
import clickhouse_connect
client = clickhouse_connect.get_client(
host="localhost",
port="8123",
user="my_readonly_user",
password="Str0ngP@ssw0rd",
)
query= """SELECT * FROM test_db.table WHERE a = 'test' SETTINGS SQL_RO_my_rls_key='test'"""
res = client.query(query)
print(res)- Passing settings to the query breaks
```sql
import clickhouse_connect
client = clickhouse_connect.get_client(
host="localhost",
port="8123",
user="my_readonly_user",
password="Str0ngP@ssw0rd",
)
query= """SELECT * FROM test_db.table WHERE a = 'test'"""
res = client.query(query, settings={"SQL_RO_my_rls_key": 'test'})
print(res)This results in
Query execution failed: Setting SQL_RO_my_rls_key is unknown or readonly
Environment
- clickhouse-connect version: 0.8.18
- Python version: 3.12
- Operating system: Debian (modal.com)
- Clickhouse cloud: version 25.4
Context
I am trying to follow this blog post https://www.highlight.io/blog/row-level-security
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working