activerecord-tenant-level-security 0.8.0 → 0.9.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/.circleci/config.yml +2 -2
- data/CHANGELOG.md +8 -0
- data/README.md +13 -0
- data/activerecord-tenant-level-security.gemspec +2 -2
- data/lib/activerecord-tenant-level-security/tenant_level_security.rb +6 -0
- data/lib/activerecord-tenant-level-security/version.rb +1 -1
- metadata +7 -8
- data/gemfiles/rails_8.0.gemfile +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4d40f1c1768bb2f2b919da77466f28d217583697440a9d884ec7f536f7b1f82
|
|
4
|
+
data.tar.gz: 7a39525b94e40cdefec33508051c3ed8c35fa8120611c3ffe2c03c3479de4773
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5774048a2a095d55dad01d33efcb43d59562efc9170fe0f8a3a779eabd82f43d3efefd80c9b8f4723247a3ccc8b5d080ab1ecf352b694fbeb214572c9a2c844
|
|
7
|
+
data.tar.gz: 6e7ac11bfb709ff60850ab248aa13e81a31aaed9368388e17cbe75dcd0766dc7d245e38706f1605917e88b81fac6a7f3226f1b9a175876fac44753dab84dc39e
|
data/.circleci/config.yml
CHANGED
|
@@ -29,5 +29,5 @@ workflows:
|
|
|
29
29
|
matrix:
|
|
30
30
|
parameters:
|
|
31
31
|
ruby: ['ruby:3.3', 'ruby:3.4', 'ruby:4.0']
|
|
32
|
-
rails: ['rails_8.
|
|
33
|
-
postgres: ['postgres:
|
|
32
|
+
rails: ['rails_8.1']
|
|
33
|
+
postgres: ['postgres:15.20', 'postgres:16.16', 'postgres:17.12', 'postgres:18.7', 'postgres:19.0']
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## v0.9.0 (2026-12-01)
|
|
2
|
+
|
|
3
|
+
### Breaking Changes
|
|
4
|
+
- [#41](https://github.com/kufu/activerecord-tenant-level-security/pull/41): Drop support for Rails 8.0 and PostgreSQL 14. Add support for PostgreSQL 19
|
|
5
|
+
|
|
6
|
+
### Enhancements
|
|
7
|
+
- [#40](https://github.com/kufu/activerecord-tenant-level-security/pull/40): Allow opting out of switching the session per database
|
|
8
|
+
|
|
1
9
|
## v0.8.0 (2026-09-07)
|
|
2
10
|
|
|
3
11
|
### Breaking Changes
|
data/README.md
CHANGED
|
@@ -140,6 +140,19 @@ Active Record 6+ adds support for [multiple databases](https://guides.rubyonrail
|
|
|
140
140
|
|
|
141
141
|
In multiple databases, Active Record creates a connection pool for each connection, but `TenantLevelSecurity.switch` only switches for the current connection.
|
|
142
142
|
|
|
143
|
+
The session is switched on all connections by default. If you use other databases together, such as MySQL which rejects the SET statement,
|
|
144
|
+
set `tenant_level_security: false` to them in `config/database.yml`:
|
|
145
|
+
|
|
146
|
+
```yml
|
|
147
|
+
production:
|
|
148
|
+
primary:
|
|
149
|
+
adapter: postgresql
|
|
150
|
+
tenant_level_security: true
|
|
151
|
+
legacy:
|
|
152
|
+
adapter: mysql2
|
|
153
|
+
tenant_level_security: false # Do not switch the session on this database
|
|
154
|
+
```
|
|
155
|
+
|
|
143
156
|
## Testing with Rails Fixtures
|
|
144
157
|
|
|
145
158
|
When testing a Rails app with multiple tenants, you might have fixtures for different tenants that need loading into
|
|
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
end
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
|
|
27
|
-
spec.add_dependency "activerecord", ">= 8.
|
|
28
|
-
spec.add_dependency "activesupport", ">= 8.
|
|
27
|
+
spec.add_dependency "activerecord", ">= 8.1"
|
|
28
|
+
spec.add_dependency "activesupport", ">= 8.1"
|
|
29
29
|
spec.add_dependency "pg", ">= 1.0"
|
|
30
30
|
|
|
31
31
|
spec.add_development_dependency "bundler", ">= 2.0"
|
|
@@ -42,7 +42,13 @@ module TenantLevelSecurity
|
|
|
42
42
|
)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def enabled_for?(db_config)
|
|
46
|
+
db_config.configuration_hash[:tenant_level_security] != false
|
|
47
|
+
end
|
|
48
|
+
|
|
45
49
|
def switch_with_connection!(conn, tenant_id)
|
|
50
|
+
return unless enabled_for?(conn.pool.db_config)
|
|
51
|
+
|
|
46
52
|
conn.clear_query_cache
|
|
47
53
|
|
|
48
54
|
if tenant_id.present?
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-tenant-level-security
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SmartHR
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '8.
|
|
18
|
+
version: '8.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '8.
|
|
25
|
+
version: '8.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: activesupport
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.
|
|
32
|
+
version: '8.1'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '8.
|
|
39
|
+
version: '8.1'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: pg
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -115,7 +115,6 @@ files:
|
|
|
115
115
|
- bin/console
|
|
116
116
|
- bin/setup
|
|
117
117
|
- compose.yml
|
|
118
|
-
- gemfiles/rails_8.0.gemfile
|
|
119
118
|
- gemfiles/rails_8.1.gemfile
|
|
120
119
|
- lib/activerecord-tenant-level-security.rb
|
|
121
120
|
- lib/activerecord-tenant-level-security/command_recorder.rb
|
|
@@ -131,7 +130,7 @@ licenses:
|
|
|
131
130
|
metadata:
|
|
132
131
|
homepage_uri: https://github.com/kufu/activerecord-tenant-level-security
|
|
133
132
|
source_code_uri: https://github.com/kufu/activerecord-tenant-level-security
|
|
134
|
-
changelog_uri: https://github.com/kufu/activerecord-tenant-level-security/blob/v0.
|
|
133
|
+
changelog_uri: https://github.com/kufu/activerecord-tenant-level-security/blob/v0.9.0/CHANGELOG.md
|
|
135
134
|
rdoc_options: []
|
|
136
135
|
require_paths:
|
|
137
136
|
- lib
|
|
@@ -146,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
146
145
|
- !ruby/object:Gem::Version
|
|
147
146
|
version: '0'
|
|
148
147
|
requirements: []
|
|
149
|
-
rubygems_version:
|
|
148
|
+
rubygems_version: 4.0.10
|
|
150
149
|
specification_version: 4
|
|
151
150
|
summary: An Active Record extension for Multitenancy with PostgreSQL Row Level Security
|
|
152
151
|
test_files: []
|