privileges.td 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # IMPORTANT: The Postgres server has a custom pg_hba.conf that only
  10. # accepts connections from specific users. You will have to update
  11. # pg_hba.conf if you modify the existing user names or add new ones.
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE USER priv WITH PASSWORD 'priv';
  14. ALTER USER priv WITH replication;
  15. CREATE SCHEMA other;
  16. CREATE TABLE other.s (a int);
  17. GRANT ALL PRIVILEGES ON SCHEMA other TO priv;
  18. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA other TO priv;
  19. CREATE TABLE public.t (a int);
  20. GRANT ALL PRIVILEGES ON SCHEMA public TO priv;
  21. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO priv;
  22. DROP PUBLICATION IF EXISTS mz_source;
  23. CREATE PUBLICATION mz_source FOR ALL TABLES;
  24. REVOKE CONNECT ON DATABASE postgres FROM public;
  25. #
  26. # CONNECT error
  27. #
  28. > CREATE SECRET pgpass AS 'priv'
  29. ! CREATE CONNECTION pg TO POSTGRES (
  30. HOST postgres,
  31. DATABASE postgres,
  32. USER priv,
  33. PASSWORD SECRET pgpass
  34. )
  35. contains:permission denied for database "postgres"
  36. #
  37. # USAGE error
  38. #
  39. $ postgres-execute connection=postgres://postgres:postgres@postgres
  40. GRANT CONNECT ON DATABASE postgres TO public;
  41. REVOKE USAGE ON SCHEMA other FROM priv;
  42. > CREATE CONNECTION pg TO POSTGRES (
  43. HOST postgres,
  44. DATABASE postgres,
  45. USER priv,
  46. PASSWORD SECRET pgpass
  47. )
  48. ! CREATE SOURCE mz_source
  49. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  50. FOR SCHEMAS(public, other);
  51. contains:insufficient privileges
  52. detail:user priv lacks USAGE privileges for schemas other
  53. #
  54. # SELECT errors
  55. #
  56. $ postgres-execute connection=postgres://postgres:postgres@postgres
  57. GRANT ALL PRIVILEGES ON SCHEMA other TO priv;
  58. REVOKE SELECT ON TABLE other.s FROM priv;
  59. ! CREATE SOURCE mz_source
  60. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  61. FOR SCHEMAS(public, other);
  62. contains:insufficient privileges
  63. detail:user priv lacks SELECT privileges for tables other.s
  64. $ postgres-execute connection=postgres://postgres:postgres@postgres
  65. CREATE TABLE "select" (a INT);
  66. REVOKE SELECT ON public.select FROM priv;
  67. CREATE TABLE """select""" (a INT);
  68. REVOKE SELECT ON public."""select""" FROM priv;
  69. ! CREATE SOURCE mz_source
  70. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  71. FOR SCHEMAS(public);
  72. contains:insufficient privileges
  73. detail:user priv lacks SELECT privileges for tables public."""select""", public."select"
  74. $ postgres-execute connection=postgres://postgres:postgres@postgres
  75. DROP SCHEMA IF EXISTS other CASCADE;