mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 00:02:13 +00:00
fix(datatables): hide schemas the connection cannot enter from the tree
The right join is what keeps an empty schema in the list, and it reads pg_namespace, which every role can read in full — so a schema the role has no privilege on came back too, as an empty one, since information_schema does filter. An empty schema it can enter still shows.
This commit is contained in:
@@ -280,9 +280,14 @@ const scriptsV2: typeof legacyScripts = {
|
||||
...legacyScripts,
|
||||
postgresql: {
|
||||
...legacyScripts.postgresql,
|
||||
// The right join is what keeps a schema with no table in the list. It reads
|
||||
// `pg_namespace`, which every role can read in full, so without the
|
||||
// privilege check a schema the connection cannot enter shows up too — as an
|
||||
// empty one, since `information_schema.columns` does filter by privilege.
|
||||
code: `
|
||||
SELECT table_name, column_name, udt_name, column_default, is_nullable, nsp.nspname AS table_schema FROM information_schema.columns
|
||||
RIGHT JOIN pg_namespace nsp ON table_schema = nsp.nspname WHERE nsp.nspname NOT IN ('information_schema', 'pg_toast', 'pg_catalog')`
|
||||
RIGHT JOIN pg_namespace nsp ON table_schema = nsp.nspname WHERE nsp.nspname NOT IN ('information_schema', 'pg_toast', 'pg_catalog')
|
||||
AND nsp.nspname NOT LIKE 'pg\\_%' AND has_schema_privilege(nsp.oid, 'USAGE, CREATE')`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user