pg_rls 0.2.5 → 1.0.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 +4 -4
- data/.rubocop.yml +55 -17
- data/.ruby-version +1 -0
- data/CHANGELOG.md +19 -2
- data/CODE_OF_CONDUCT.md +77 -29
- data/Guardfile +44 -0
- data/README.md +247 -83
- data/Rakefile +5 -12
- data/Steepfile +29 -0
- data/UPGRADE.md +106 -0
- data/app/models/pg_rls/admin.rb +24 -0
- data/app/models/pg_rls/current.rb +48 -0
- data/app/models/pg_rls/record.rb +13 -0
- data/app/models/pg_rls/tenant/searchable.rb +60 -0
- data/app/models/pg_rls/tenant/securable.rb +67 -0
- data/app/models/pg_rls/tenant/switchable.rb +40 -0
- data/app/models/pg_rls/tenant.rb +9 -0
- data/assets/logo.svg +8 -0
- data/docker-compose.yml +14 -0
- data/lib/generators/pg_rls/active_record/active_record_generator.rb +62 -65
- data/lib/generators/pg_rls/install/install_generator.rb +38 -0
- data/lib/generators/pg_rls/pg_rls_generator.rb +2 -1
- data/lib/generators/pg_rls/templates/USAGE +28 -0
- data/lib/generators/pg_rls/templates/app/models/abstract_base_class.rb.tt +7 -0
- data/lib/generators/pg_rls/templates/app/models/model.rb.tt +22 -0
- data/lib/generators/pg_rls/templates/config/initializers/pg_rls.rb.tt +58 -0
- data/lib/generators/pg_rls/templates/db/migrate/backport_pg_rls_table.rb.tt +14 -0
- data/lib/generators/pg_rls/templates/db/migrate/convert_to_pg_rls_table.rb.tt +5 -0
- data/lib/generators/pg_rls/templates/db/migrate/convert_to_pg_rls_tenant_table.rb.tt +5 -0
- data/lib/generators/pg_rls/templates/db/migrate/create_pg_rls_table.rb.tt +29 -0
- data/lib/generators/pg_rls/templates/db/migrate/create_pg_rls_tenant_table.rb.tt +29 -0
- data/lib/pg_rls/active_record/connection_adapters/connection_pool.rb +31 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/check_rls_user_privileges.rb +207 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/errors.rb +17 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/grant_rls_user_privileges.rb +167 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb +91 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_policies.rb +56 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_triggers.rb +95 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_user_statements.rb +127 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/schema_dumper.rb +71 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/schema_statements.rb +120 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql/sql_helper_method.rb +30 -0
- data/lib/pg_rls/active_record/connection_adapters/postgre_sql.rb +36 -0
- data/lib/pg_rls/active_record/connection_adapters.rb +12 -0
- data/lib/pg_rls/active_record/database_shards.rb +74 -0
- data/lib/pg_rls/active_record/migration/command_recorder.rb +28 -0
- data/lib/pg_rls/active_record/migration.rb +11 -0
- data/lib/pg_rls/active_record/test_databases.rb +19 -0
- data/lib/pg_rls/active_record.rb +11 -0
- data/lib/pg_rls/active_support/string_ext.rb +17 -0
- data/lib/pg_rls/active_support.rb +9 -0
- data/lib/pg_rls/connection_config.rb +61 -0
- data/lib/pg_rls/deprecation.rb +14 -0
- data/lib/pg_rls/engine.rb +8 -0
- data/lib/pg_rls/error.rb +10 -0
- data/lib/pg_rls/generators/.keep +0 -0
- data/lib/pg_rls/railtie.rb +1 -11
- data/lib/pg_rls/tasks/.keep +0 -0
- data/lib/pg_rls/version.rb +3 -1
- data/lib/pg_rls.rb +67 -151
- data/rbs_collection.lock.yaml +132 -0
- data/rbs_collection.yaml +127 -0
- data/review_code.sh +33 -0
- data/sig/generators/pg_rls/active_record/active_record_generator.rbs +43 -0
- data/sig/generators/pg_rls/install/install_generator.rbs +20 -0
- data/sig/generators/pg_rls/pg_rls_generator.rbs +9 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/check_rls_user_privileges.rbs +53 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/errors.rbs +24 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/grant_rls_user_privileges.rbs +55 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rbs +31 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_policies.rbs +28 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_triggers.rbs +35 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/rls_user_statements.rbs +48 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/schema_dumper.rbs +38 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/schema_statements.rbs +67 -0
- data/sig/pg_rls/active_record/connection_adapters/postgre_sql/sql_helper_method.rbs +21 -0
- data/sig/pg_rls/active_record/connection_adapters/postgresql.rbs +10 -0
- data/sig/pg_rls/active_record/connection_adapters.rbs +50 -0
- data/sig/pg_rls/active_record/database_shards.rbs +34 -0
- data/sig/pg_rls/active_record/migration/command_recorder.rbs +14 -0
- data/sig/pg_rls/active_record/migration.rbs +8 -0
- data/sig/pg_rls/active_record.rbs +7 -0
- data/sig/pg_rls/active_support/hash_ext.rbs +11 -0
- data/sig/pg_rls/active_support/string_ext.rbs +27 -0
- data/sig/pg_rls/active_support.rbs +7 -0
- data/sig/pg_rls/app/models/pg_rls/record.rbs +4 -0
- data/sig/pg_rls/connection_config.rbs +16 -0
- data/sig/pg_rls/deprecation.rbs +9 -0
- data/sig/pg_rls/engine.rbs +7 -0
- data/sig/pg_rls/errors.rbs +14 -0
- data/sig/pg_rls/railtie.rbs +6 -0
- data/sig/pg_rls/tenant_test_helper.rbs +14 -0
- data/sig/pg_rls.rbs +60 -0
- data/sig/support/active_record.rbs +86 -0
- data/sig/support/active_support.rbs +7 -0
- data/sig/support/fowardable.rbs +2 -0
- data/sig/support/pg.rbs +12 -0
- data/sig/support/rails.rbs +38 -0
- data/start.sh +30 -0
- metadata +167 -12
- data/Gemfile +0 -21
- data/Gemfile.lock +0 -300
- data/bin/console +0 -15
- data/bin/setup +0 -8
data/Gemfile.lock
DELETED
@@ -1,300 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pg_rls (0.1.10)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
actioncable (7.1.1)
|
10
|
-
actionpack (= 7.1.1)
|
11
|
-
activesupport (= 7.1.1)
|
12
|
-
nio4r (~> 2.0)
|
13
|
-
websocket-driver (>= 0.6.1)
|
14
|
-
zeitwerk (~> 2.6)
|
15
|
-
actionmailbox (7.1.1)
|
16
|
-
actionpack (= 7.1.1)
|
17
|
-
activejob (= 7.1.1)
|
18
|
-
activerecord (= 7.1.1)
|
19
|
-
activestorage (= 7.1.1)
|
20
|
-
activesupport (= 7.1.1)
|
21
|
-
mail (>= 2.7.1)
|
22
|
-
net-imap
|
23
|
-
net-pop
|
24
|
-
net-smtp
|
25
|
-
actionmailer (7.1.1)
|
26
|
-
actionpack (= 7.1.1)
|
27
|
-
actionview (= 7.1.1)
|
28
|
-
activejob (= 7.1.1)
|
29
|
-
activesupport (= 7.1.1)
|
30
|
-
mail (~> 2.5, >= 2.5.4)
|
31
|
-
net-imap
|
32
|
-
net-pop
|
33
|
-
net-smtp
|
34
|
-
rails-dom-testing (~> 2.2)
|
35
|
-
actionpack (7.1.1)
|
36
|
-
actionview (= 7.1.1)
|
37
|
-
activesupport (= 7.1.1)
|
38
|
-
nokogiri (>= 1.8.5)
|
39
|
-
rack (>= 2.2.4)
|
40
|
-
rack-session (>= 1.0.1)
|
41
|
-
rack-test (>= 0.6.3)
|
42
|
-
rails-dom-testing (~> 2.2)
|
43
|
-
rails-html-sanitizer (~> 1.6)
|
44
|
-
actiontext (7.1.1)
|
45
|
-
actionpack (= 7.1.1)
|
46
|
-
activerecord (= 7.1.1)
|
47
|
-
activestorage (= 7.1.1)
|
48
|
-
activesupport (= 7.1.1)
|
49
|
-
globalid (>= 0.6.0)
|
50
|
-
nokogiri (>= 1.8.5)
|
51
|
-
actionview (7.1.1)
|
52
|
-
activesupport (= 7.1.1)
|
53
|
-
builder (~> 3.1)
|
54
|
-
erubi (~> 1.11)
|
55
|
-
rails-dom-testing (~> 2.2)
|
56
|
-
rails-html-sanitizer (~> 1.6)
|
57
|
-
activejob (7.1.1)
|
58
|
-
activesupport (= 7.1.1)
|
59
|
-
globalid (>= 0.3.6)
|
60
|
-
activemodel (7.1.1)
|
61
|
-
activesupport (= 7.1.1)
|
62
|
-
activerecord (7.1.1)
|
63
|
-
activemodel (= 7.1.1)
|
64
|
-
activesupport (= 7.1.1)
|
65
|
-
timeout (>= 0.4.0)
|
66
|
-
activestorage (7.1.1)
|
67
|
-
actionpack (= 7.1.1)
|
68
|
-
activejob (= 7.1.1)
|
69
|
-
activerecord (= 7.1.1)
|
70
|
-
activesupport (= 7.1.1)
|
71
|
-
marcel (~> 1.0)
|
72
|
-
activesupport (7.1.1)
|
73
|
-
base64
|
74
|
-
bigdecimal
|
75
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
76
|
-
connection_pool (>= 2.2.5)
|
77
|
-
drb
|
78
|
-
i18n (>= 1.6, < 2)
|
79
|
-
minitest (>= 5.1)
|
80
|
-
mutex_m
|
81
|
-
tzinfo (~> 2.0)
|
82
|
-
ast (2.4.2)
|
83
|
-
backport (1.2.0)
|
84
|
-
base64 (0.1.1)
|
85
|
-
benchmark (0.2.1)
|
86
|
-
bigdecimal (3.1.4)
|
87
|
-
builder (3.2.4)
|
88
|
-
concurrent-ruby (1.2.2)
|
89
|
-
connection_pool (2.4.1)
|
90
|
-
crass (1.0.6)
|
91
|
-
date (3.3.3)
|
92
|
-
diff-lcs (1.5.0)
|
93
|
-
drb (2.1.1)
|
94
|
-
ruby2_keywords
|
95
|
-
e2mmap (0.1.0)
|
96
|
-
erubi (1.12.0)
|
97
|
-
globalid (1.2.1)
|
98
|
-
activesupport (>= 6.1)
|
99
|
-
i18n (1.14.1)
|
100
|
-
concurrent-ruby (~> 1.0)
|
101
|
-
io-console (0.6.0)
|
102
|
-
irb (1.8.1)
|
103
|
-
rdoc
|
104
|
-
reline (>= 0.3.8)
|
105
|
-
jaro_winkler (1.5.6)
|
106
|
-
json (2.6.3)
|
107
|
-
kramdown (2.4.0)
|
108
|
-
rexml
|
109
|
-
kramdown-parser-gfm (1.1.0)
|
110
|
-
kramdown (~> 2.0)
|
111
|
-
language_server-protocol (3.17.0.3)
|
112
|
-
logger (1.6.0)
|
113
|
-
loofah (2.21.4)
|
114
|
-
crass (~> 1.0.2)
|
115
|
-
nokogiri (>= 1.12.0)
|
116
|
-
mail (2.8.1)
|
117
|
-
mini_mime (>= 0.1.1)
|
118
|
-
net-imap
|
119
|
-
net-pop
|
120
|
-
net-smtp
|
121
|
-
marcel (1.0.2)
|
122
|
-
mini_mime (1.1.5)
|
123
|
-
minitest (5.20.0)
|
124
|
-
mutex_m (0.1.2)
|
125
|
-
net-imap (0.4.1)
|
126
|
-
date
|
127
|
-
net-protocol
|
128
|
-
net-pop (0.1.2)
|
129
|
-
net-protocol
|
130
|
-
net-protocol (0.2.1)
|
131
|
-
timeout
|
132
|
-
net-smtp (0.4.0)
|
133
|
-
net-protocol
|
134
|
-
nio4r (2.5.9)
|
135
|
-
nokogiri (1.15.4-arm64-darwin)
|
136
|
-
racc (~> 1.4)
|
137
|
-
nokogiri (1.15.4-x86_64-linux)
|
138
|
-
racc (~> 1.4)
|
139
|
-
parallel (1.23.0)
|
140
|
-
parser (3.2.2.4)
|
141
|
-
ast (~> 2.4.1)
|
142
|
-
racc
|
143
|
-
psych (5.1.1)
|
144
|
-
stringio
|
145
|
-
racc (1.7.1)
|
146
|
-
rack (3.0.8)
|
147
|
-
rack-session (2.0.0)
|
148
|
-
rack (>= 3.0.0)
|
149
|
-
rack-test (2.1.0)
|
150
|
-
rack (>= 1.3)
|
151
|
-
rackup (2.1.0)
|
152
|
-
rack (>= 3)
|
153
|
-
webrick (~> 1.8)
|
154
|
-
rails (7.1.1)
|
155
|
-
actioncable (= 7.1.1)
|
156
|
-
actionmailbox (= 7.1.1)
|
157
|
-
actionmailer (= 7.1.1)
|
158
|
-
actionpack (= 7.1.1)
|
159
|
-
actiontext (= 7.1.1)
|
160
|
-
actionview (= 7.1.1)
|
161
|
-
activejob (= 7.1.1)
|
162
|
-
activemodel (= 7.1.1)
|
163
|
-
activerecord (= 7.1.1)
|
164
|
-
activestorage (= 7.1.1)
|
165
|
-
activesupport (= 7.1.1)
|
166
|
-
bundler (>= 1.15.0)
|
167
|
-
railties (= 7.1.1)
|
168
|
-
rails-dom-testing (2.2.0)
|
169
|
-
activesupport (>= 5.0.0)
|
170
|
-
minitest
|
171
|
-
nokogiri (>= 1.6)
|
172
|
-
rails-html-sanitizer (1.6.0)
|
173
|
-
loofah (~> 2.21)
|
174
|
-
nokogiri (~> 1.14)
|
175
|
-
railties (7.1.1)
|
176
|
-
actionpack (= 7.1.1)
|
177
|
-
activesupport (= 7.1.1)
|
178
|
-
irb
|
179
|
-
rackup (>= 1.0.0)
|
180
|
-
rake (>= 12.2)
|
181
|
-
thor (~> 1.0, >= 1.2.2)
|
182
|
-
zeitwerk (~> 2.6)
|
183
|
-
rainbow (3.1.1)
|
184
|
-
rake (13.0.6)
|
185
|
-
rbs (2.8.4)
|
186
|
-
rdoc (6.5.0)
|
187
|
-
psych (>= 4.0.0)
|
188
|
-
redis-client (0.22.2)
|
189
|
-
connection_pool
|
190
|
-
regexp_parser (2.8.2)
|
191
|
-
reline (0.3.9)
|
192
|
-
io-console (~> 0.5)
|
193
|
-
reverse_markdown (2.1.1)
|
194
|
-
nokogiri
|
195
|
-
rexml (3.2.6)
|
196
|
-
rspec (3.12.0)
|
197
|
-
rspec-core (~> 3.12.0)
|
198
|
-
rspec-expectations (~> 3.12.0)
|
199
|
-
rspec-mocks (~> 3.12.0)
|
200
|
-
rspec-core (3.12.2)
|
201
|
-
rspec-support (~> 3.12.0)
|
202
|
-
rspec-expectations (3.12.3)
|
203
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
204
|
-
rspec-support (~> 3.12.0)
|
205
|
-
rspec-mocks (3.12.6)
|
206
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
207
|
-
rspec-support (~> 3.12.0)
|
208
|
-
rspec-support (3.12.1)
|
209
|
-
rubocop (1.57.0)
|
210
|
-
base64 (~> 0.1.1)
|
211
|
-
json (~> 2.3)
|
212
|
-
language_server-protocol (>= 3.17.0)
|
213
|
-
parallel (~> 1.10)
|
214
|
-
parser (>= 3.2.2.4)
|
215
|
-
rainbow (>= 2.2.2, < 4.0)
|
216
|
-
regexp_parser (>= 1.8, < 3.0)
|
217
|
-
rexml (>= 3.2.5, < 4.0)
|
218
|
-
rubocop-ast (>= 1.28.1, < 2.0)
|
219
|
-
ruby-progressbar (~> 1.7)
|
220
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
221
|
-
rubocop-ast (1.29.0)
|
222
|
-
parser (>= 3.2.1.0)
|
223
|
-
rubocop-capybara (2.19.0)
|
224
|
-
rubocop (~> 1.41)
|
225
|
-
rubocop-factory_bot (2.24.0)
|
226
|
-
rubocop (~> 1.33)
|
227
|
-
rubocop-performance (1.19.1)
|
228
|
-
rubocop (>= 1.7.0, < 2.0)
|
229
|
-
rubocop-ast (>= 0.4.0)
|
230
|
-
rubocop-rails (2.21.2)
|
231
|
-
activesupport (>= 4.2.0)
|
232
|
-
rack (>= 1.1)
|
233
|
-
rubocop (>= 1.33.0, < 2.0)
|
234
|
-
rubocop-rake (0.6.0)
|
235
|
-
rubocop (~> 1.0)
|
236
|
-
rubocop-rspec (2.24.1)
|
237
|
-
rubocop (~> 1.33)
|
238
|
-
rubocop-capybara (~> 2.17)
|
239
|
-
rubocop-factory_bot (~> 2.22)
|
240
|
-
ruby-progressbar (1.13.0)
|
241
|
-
ruby2_keywords (0.0.5)
|
242
|
-
sidekiq (7.3.1)
|
243
|
-
concurrent-ruby (< 2)
|
244
|
-
connection_pool (>= 2.3.0)
|
245
|
-
logger
|
246
|
-
rack (>= 2.2.4)
|
247
|
-
redis-client (>= 0.22.2)
|
248
|
-
solargraph (0.49.0)
|
249
|
-
backport (~> 1.2)
|
250
|
-
benchmark
|
251
|
-
bundler (~> 2.0)
|
252
|
-
diff-lcs (~> 1.4)
|
253
|
-
e2mmap
|
254
|
-
jaro_winkler (~> 1.5)
|
255
|
-
kramdown (~> 2.3)
|
256
|
-
kramdown-parser-gfm (~> 1.1)
|
257
|
-
parser (~> 3.0)
|
258
|
-
rbs (~> 2.0)
|
259
|
-
reverse_markdown (~> 2.0)
|
260
|
-
rubocop (~> 1.38)
|
261
|
-
thor (~> 1.0)
|
262
|
-
tilt (~> 2.0)
|
263
|
-
yard (~> 0.9, >= 0.9.24)
|
264
|
-
stringio (3.0.8)
|
265
|
-
thor (1.2.2)
|
266
|
-
tilt (2.3.0)
|
267
|
-
timeout (0.4.0)
|
268
|
-
tzinfo (2.0.6)
|
269
|
-
concurrent-ruby (~> 1.0)
|
270
|
-
unicode-display_width (2.5.0)
|
271
|
-
webrick (1.8.1)
|
272
|
-
websocket-driver (0.7.6)
|
273
|
-
websocket-extensions (>= 0.1.0)
|
274
|
-
websocket-extensions (0.1.5)
|
275
|
-
yard (0.9.34)
|
276
|
-
zeitwerk (2.6.12)
|
277
|
-
|
278
|
-
PLATFORMS
|
279
|
-
arm64-darwin-22
|
280
|
-
arm64-darwin-23
|
281
|
-
x86_64-linux
|
282
|
-
|
283
|
-
DEPENDENCIES
|
284
|
-
pg_rls!
|
285
|
-
rails (~> 7.0, >= 7.0.4)
|
286
|
-
rake
|
287
|
-
rspec
|
288
|
-
rubocop
|
289
|
-
rubocop-performance
|
290
|
-
rubocop-rails
|
291
|
-
rubocop-rake
|
292
|
-
rubocop-rspec
|
293
|
-
sidekiq
|
294
|
-
solargraph
|
295
|
-
|
296
|
-
RUBY VERSION
|
297
|
-
ruby 3.2.2p53
|
298
|
-
|
299
|
-
BUNDLED WITH
|
300
|
-
2.4.22
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'pg_rls'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|