rls_multi_tenant 0.1.7 → 0.1.9
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 +4 -4
- data/.rspec +3 -0
- data/.rubocop.yml +2 -2
- data/README.md +7 -0
- data/lib/rls_multi_tenant/generators/shared/templates/create_app_user.rb +7 -3
- data/lib/rls_multi_tenant/security_validator.rb +2 -2
- data/lib/rls_multi_tenant/version.rb +1 -1
- data/rls_multi_tenant.gemspec +1 -0
- metadata +18 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b45cd6b953bae2321b231e78d3883eba2432803c44e036e4d6845269aef3633b
|
|
4
|
+
data.tar.gz: cf4f8900c3577c532fb82638a4064b239dd99611136b282560d06c6ba2e396bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eacdf26741563c4a9d4a25f6db59d55e1ebc8035f6804d4f19695178f9cf9da3bdd49e04f09173b33c4641a2ef3024987091250b4fc0d32a6736720ff56c1feb
|
|
7
|
+
data.tar.gz: 82257c569f87e8beff78a914ecfc0948a281835a10306e71ff8238ca71e403b25c32845ed7e710a2ef890eaa68ec9f525f130811c4c1a1bca6e1d4a3948028bd
|
data/.rspec
ADDED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# RLS Multi-Tenant
|
|
2
2
|
|
|
3
|
+
[](https://github.com/codingways/rls_multi_tenant/actions/workflows/simple.yml)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
5
|
+
[](https://rubyonrails.org/)
|
|
6
|
+
[](https://badge.fury.io/rb/rls_multi_tenant)
|
|
7
|
+
[](https://rubygems.org/gems/rls_multi_tenant)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
3
10
|
A Rails gem that provides PostgreSQL Row Level Security (RLS) based multi-tenancy for Rails applications.
|
|
4
11
|
|
|
5
12
|
## Features
|
|
@@ -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};"
|
|
@@ -48,8 +48,8 @@ module RlsMultiTenant
|
|
|
48
48
|
private
|
|
49
49
|
|
|
50
50
|
def skip_validation?
|
|
51
|
-
# Skip validation if we're running install generator
|
|
52
|
-
return true if ARGV.any? { |arg| arg.include?('rls_multi_tenant:install') }
|
|
51
|
+
# Skip validation if we're running an install or setup generator
|
|
52
|
+
return true if ARGV.any? { |arg| arg.include?('rls_multi_tenant:install') || arg.include?('rls_multi_tenant:setup') }
|
|
53
53
|
|
|
54
54
|
# Skip validation if we're in admin mode (set by db_as:admin task)
|
|
55
55
|
return true if ENV['RLS_MULTI_TENANT_ADMIN_MODE'] == 'true'
|
data/rls_multi_tenant.gemspec
CHANGED
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
# Dependencies
|
|
35
35
|
spec.add_dependency "rails", ">= 6.0", "< 9.0"
|
|
36
36
|
spec.add_dependency "pg", ">= 1.0", "< 3.0"
|
|
37
|
+
spec.add_dependency "ostruct", ">= 0.1.0"
|
|
37
38
|
|
|
38
39
|
# Development dependencies
|
|
39
40
|
spec.add_development_dependency "rspec-rails", "~> 6.0"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rls_multi_tenant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Coding Ways
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -50,6 +49,20 @@ dependencies:
|
|
|
50
49
|
- - "<"
|
|
51
50
|
- !ruby/object:Gem::Version
|
|
52
51
|
version: '3.0'
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: ostruct
|
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: 0.1.0
|
|
59
|
+
type: :runtime
|
|
60
|
+
prerelease: false
|
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: 0.1.0
|
|
53
66
|
- !ruby/object:Gem::Dependency
|
|
54
67
|
name: rspec-rails
|
|
55
68
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -157,6 +170,7 @@ executables: []
|
|
|
157
170
|
extensions: []
|
|
158
171
|
extra_rdoc_files: []
|
|
159
172
|
files:
|
|
173
|
+
- ".rspec"
|
|
160
174
|
- ".rubocop.yml"
|
|
161
175
|
- README.md
|
|
162
176
|
- lib/rls_multi_tenant.rb
|
|
@@ -193,7 +207,6 @@ metadata:
|
|
|
193
207
|
changelog_uri: https://github.com/codingways/rls_multi_tenant/blob/main/CHANGELOG.md
|
|
194
208
|
bug_tracker_uri: https://github.com/codingways/rls_multi_tenant/issues
|
|
195
209
|
documentation_uri: https://github.com/codingways/rls_multi_tenant#readme
|
|
196
|
-
post_install_message:
|
|
197
210
|
rdoc_options: []
|
|
198
211
|
require_paths:
|
|
199
212
|
- lib
|
|
@@ -208,8 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
208
221
|
- !ruby/object:Gem::Version
|
|
209
222
|
version: '0'
|
|
210
223
|
requirements: []
|
|
211
|
-
rubygems_version: 3.
|
|
212
|
-
signing_key:
|
|
224
|
+
rubygems_version: 3.6.9
|
|
213
225
|
specification_version: 4
|
|
214
226
|
summary: Rails gem for PostgreSQL Row Level Security (RLS) multi-tenant applications
|
|
215
227
|
test_files: []
|