@kontrolia/db 2.1.1 → 2.1.3

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.
@@ -0,0 +1,20 @@
1
+ -- Lets an application's own row remember which GoTrue OAuth 2.1 client it
2
+ -- registered, so admin-panel can manage OAuth-client credentials from
3
+ -- inside that application's row instead of a separate, disconnected
4
+ -- top-level "Clientes OAuth" screen. No real FK is possible — GoTrue's
5
+ -- OAuth clients live entirely outside this schema, reachable only via its
6
+ -- own admin HTTP API (see apps/auth-server/app/api/oauth-clients/route.ts),
7
+ -- not a Postgres table this database has any relationship to. This is
8
+ -- purely a pointer, populated by the application layer after a successful
9
+ -- POST to that route.
10
+ --
11
+ -- An old day-one migration comment (0003_applications_and_permissions.sql:
12
+ -- "oauth_clients (v2) attach real OAuth2 credentials to a row here") shows
13
+ -- this link was the original intended design; it was never implemented and
14
+ -- the two concepts drifted apart into fully separate admin-panel pages.
15
+ -- This finally closes that gap.
16
+
17
+ alter table kontrolia_auth.applications add column oauth_client_id text;
18
+
19
+ comment on column kontrolia_auth.applications.oauth_client_id is
20
+ 'GoTrue OAuth 2.1 client_id registered for this application, if any — set by admin-panel after POST /api/oauth-clients succeeds. Not a foreign key: GoTrue''s own oauth_clients table lives outside kontrolia_auth, reachable only via its admin API.';
@@ -0,0 +1,19 @@
1
+ -- Migration 0036 added applications.oauth_client_id but forgot the
2
+ -- column-level grant migration 0032 made mandatory for any new column on
3
+ -- this table: 0032 revoked the old blanket `grant select on all tables to
4
+ -- authenticated` and replaced it with an explicit per-column list, so a
5
+ -- column added later without its own grant is invisible to `authenticated`
6
+ -- — worse than invisible, actually: PostgREST's single SELECT statement
7
+ -- fails outright with "permission denied for table applications" the
8
+ -- moment oauth_client_id is included alongside the columns that ARE
9
+ -- granted, taking the whole query down with it. Live-reproduced against
10
+ -- production: apps/admin-panel's applications page select list includes
11
+ -- oauth_client_id unconditionally, so every authenticated user's query
12
+ -- failed and the entire "Aplicaciones" list rendered empty since 0036
13
+ -- shipped — not a caching or migration-timing issue, a missing grant.
14
+ --
15
+ -- Not sensitive like api_key_hash (a GoTrue client_id, not a secret), so
16
+ -- it belongs in the same broadly-readable column set as
17
+ -- owner_organization_id/homepage_url/etc., not restricted to service_role.
18
+
19
+ grant select (oauth_client_id) on kontrolia_auth.applications to authenticated;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontrolia/db",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "license": "MIT",
5
5
  "description": "KontrolIA Auth database layer: SQL migrations for the `kontrolia` schema (organizations, RBAC, Custom Access Token Hook) and a connection-string-agnostic migration runner.",
6
6
  "keywords": [