omen 0.9.0 → 0.10.1

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: c51ab71a4d3ccce3f1bdcfa1e6f4b6a8196e2778f55368e7dea902e220f367d4
4
- data.tar.gz: '003328f8dcba05fe6654e1852b8c9c18ef5e305d8c0ba95456b266c01880c546'
3
+ metadata.gz: 9698c59cc037f0a9ccbe6b100af4a7137df0d26c8a54b3a8e5c37e9effe5e5e6
4
+ data.tar.gz: 792f03229094807c6ca995cc1271a199cc158db1f54ecfebee4a3e5db242712d
5
5
  SHA512:
6
- metadata.gz: 89a995c7beebd10a587d370ba7e8762f4e92a05252985045666101e64af81f10e5b7100631d670bd12ef89fe527fd4fc744f56918d26500268a39667311ee941
7
- data.tar.gz: cf1a91b08d3e40e10d4a43a12872f2befad7cdefea114bbfe0e0e4eb78a8eb55076201ac8bf55e0bd2cd22d9a7ae3a4525367880d0a9622aa05a3d6f11e9062f
6
+ metadata.gz: 4395ce363d33978256ce75d72d6495c873af06299c140f0a61bf0fc637bda94bde5cbb129744447a01b6603ebbcaf4fb5567920d3a32c859ba86c097ef206354
7
+ data.tar.gz: 8f5c0384edd2be88dcaacb5a60cb9256c4f8c2139a5fcb351a7eae9fce3ff5619bf5403a919c9ebb6e61fe64103c94bcc80a58d9f656552568862f34ac6f8e9c
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  For more information about changelogs, check [Keep a Changelog](http://keepachangelog.com) and
6
6
  [Vandamme](http://tech-angels.github.io/vandamme).
7
7
 
8
+ ## 0.10.1 - 2026-10-14
9
+
10
+ * [Change] The narrowed role is granted the connection's current schema rather than `public`,
11
+ so a host keeping its tables in a schema of its own -- sharing a database with another app,
12
+ each in a schema -- gets a role that reads its tables and no one else's. A host that never
13
+ set a search path reads `public` as before.
14
+
8
15
  ## 0.9.0 - 2026-09-18
9
16
 
10
17
  * [Fix] An answer landing touches the reading it belongs to, so a page watching one refreshes
data/README.md CHANGED
@@ -18,7 +18,7 @@ statement returned is ever sent back.
18
18
  In your `Gemfile`, pinned to the current minor while this is still below 1.0:
19
19
 
20
20
  ```ruby
21
- gem 'omen', '~> 0.6.0'
21
+ gem 'omen', '~> 0.10.0'
22
22
  ```
23
23
 
24
24
  Then four commands:
data/lib/omen/bound.rb CHANGED
@@ -9,7 +9,7 @@ module Omen
9
9
  SELECT p.tablename, p.policyname, r.rolname FROM pg_policies p
10
10
  CROSS JOIN LATERAL unnest(p.roles) AS named(rolname)
11
11
  JOIN pg_roles r ON pg_has_role(r.oid, named.rolname::regrole::oid, 'USAGE')
12
- WHERE p.permissive = 'RESTRICTIVE' AND p.schemaname = 'public' AND NOT r.rolsuper
12
+ WHERE p.permissive = 'RESTRICTIVE' AND p.schemaname = current_schema() AND NOT r.rolsuper
13
13
  ORDER BY p.tablename, p.policyname, r.rolname
14
14
  SQL
15
15
 
data/lib/omen/grants.rb CHANGED
@@ -17,12 +17,13 @@ module Omen
17
17
  # @return [Array<String>] the statements to run, in order.
18
18
  def self.statements(connection, members)
19
19
  role = connection.quote_table_name Omen.config.narrow_role
20
+ read = schema connection
20
21
  [
21
22
  *made(connection, Omen.config.narrow_role),
22
23
  *members.map { |member| "GRANT #{role} TO #{connection.quote_table_name member}" },
23
- "GRANT USAGE ON SCHEMA public TO #{role}",
24
- "GRANT SELECT ON ALL TABLES IN SCHEMA public TO #{role}",
25
- "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO #{role}",
24
+ "GRANT USAGE ON SCHEMA #{read} TO #{role}",
25
+ "GRANT SELECT ON ALL TABLES IN SCHEMA #{read} TO #{role}",
26
+ "ALTER DEFAULT PRIVILEGES IN SCHEMA #{read} GRANT SELECT ON TABLES TO #{role}",
26
27
  *revoked(connection, role),
27
28
  *Omen::Renamed.statements,
28
29
  *Omen::TimeZone.statements(connection),
@@ -42,10 +43,15 @@ module Omen
42
43
  role = connection.quote_table_name name
43
44
  [
44
45
  *members.map { |member| apart role, connection.quote_table_name(member) },
45
- "GRANT USAGE ON SCHEMA public TO #{role}",
46
+ "GRANT USAGE ON SCHEMA #{schema connection} TO #{role}",
46
47
  ]
47
48
  end
48
49
 
50
+ # The schema a host keeps its tables in: the first of its search path, `public` by default.
51
+ # @param connection [ActiveRecord::ConnectionAdapters::AbstractAdapter] a writing one.
52
+ # @return [String] its name, quoted.
53
+ def self.schema(connection) = connection.quote_table_name connection.current_schema
54
+
49
55
  # @param role [String] the role, quoted.
50
56
  # @param member [String] the role that may enter it, quoted.
51
57
  # @return [String] the statement that lets it in without handing it what the role holds.
data/lib/omen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Omen
2
2
  # The version of this gem, as RubyGems knows it.
3
- VERSION = '0.9.0'
3
+ VERSION = '0.10.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 4.0.3
149
+ rubygems_version: 4.0.20
150
150
  specification_version: 4
151
151
  summary: Ask Claude about your own data
152
152
  test_files: []