rls_multi_tenant 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49b6d40d5e29350f1911f16aa361beaad5b1ad28dfab6da452260cd535ff6dd1
|
|
4
|
+
data.tar.gz: ba39dd57c6690a60b5d8e1ed466d7b42e25b745920ff5016030a405d89360f88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f8c83ceedec1aa0dfee0bb9ab01c8123ce6bf58a1b75a5f6b6ea5ec083803ec917d526504c9f5897a274f40bf3eb2dd6ccd856b7f9ecee69b36c0ac2d90642a
|
|
7
|
+
data.tar.gz: 6e673789ff292c0258411c9e46cf3a7a899f862771b760651acdc9c8662540fb9b1674650238a3472ac80275004f910f673ca516099b86eddc26c2151929ed23
|
|
@@ -23,9 +23,9 @@ class CreateAppUser < ActiveRecord::Migration[<%= Rails.version.to_f %>]
|
|
|
23
23
|
execute "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO #{app_user};"
|
|
24
24
|
execute "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO #{app_user};"
|
|
25
25
|
|
|
26
|
-
# Grant permissions on
|
|
27
|
-
execute "GRANT SELECT ON
|
|
28
|
-
execute "GRANT SELECT ON
|
|
26
|
+
# Grant permissions on all existing tables
|
|
27
|
+
execute "GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO #{app_user};"
|
|
28
|
+
execute "GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO #{app_user};"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def down
|
|
@@ -35,6 +35,10 @@ class CreateAppUser < ActiveRecord::Migration[<%= Rails.version.to_f %>]
|
|
|
35
35
|
execute "REVOKE ALL ON SCHEMA public FROM #{app_user};"
|
|
36
36
|
execute "REVOKE CONNECT ON DATABASE #{ActiveRecord::Base.connection.current_database} FROM #{app_user};"
|
|
37
37
|
|
|
38
|
+
# Revoke permissions from all existing tables and sequences
|
|
39
|
+
execute "REVOKE ALL ON ALL TABLES IN SCHEMA public FROM #{app_user};"
|
|
40
|
+
execute "REVOKE ALL ON ALL SEQUENCES IN SCHEMA public FROM #{app_user};"
|
|
41
|
+
|
|
38
42
|
# Revoke default permissions for future tables in public schema
|
|
39
43
|
execute "ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE SELECT, INSERT, UPDATE, DELETE ON TABLES FROM #{app_user};"
|
|
40
44
|
execute "ALTER DEFAULT PRIVILEGES IN SCHEMA public REVOKE USAGE, SELECT ON SEQUENCES FROM #{app_user};"
|
|
@@ -19,7 +19,8 @@ module RlsMultiTenant
|
|
|
19
19
|
|
|
20
20
|
if superuser_check && superuser_check['rolsuper']
|
|
21
21
|
raise SecurityError, "Database user '#{username}' has SUPERUSER privileges. " \
|
|
22
|
-
"In order to use RLS Multi-tenant, you must use a non-privileged user without SUPERUSER rights."
|
|
22
|
+
"In order to use RLS Multi-tenant, you must use a non-privileged user without SUPERUSER rights." \
|
|
23
|
+
"Did you remember to edit database.yml in order to use the POSTGRES_APP_USER and POSTGRES_APP_PASSWORD?"
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
# Log the security check result
|
|
@@ -41,7 +42,8 @@ module RlsMultiTenant
|
|
|
41
42
|
raise ConfigurationError, "#{RlsMultiTenant.app_user_env_var} environment variable must be set"
|
|
42
43
|
elsif ["postgres", "root"].include?(app_user)
|
|
43
44
|
raise SecurityError, "Cannot use privileged PostgreSQL user '#{app_user}'. " \
|
|
44
|
-
"In order to use RLS Multi-tenant, you must use a non-privileged user without SUPERUSER rights."
|
|
45
|
+
"In order to use RLS Multi-tenant, you must use a non-privileged user without SUPERUSER rights." \
|
|
46
|
+
"Did you remember to edit database.yml in order to use the POSTGRES_APP_USER and POSTGRES_APP_PASSWORD?"
|
|
45
47
|
end
|
|
46
48
|
end
|
|
47
49
|
|