@proteinjs/user-server 1.25.0 → 1.26.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.
- package/CHANGELOG.md +27 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +3 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/migrations/BackfillUserRolesArray.d.ts +8 -5
- package/dist/src/migrations/BackfillUserRolesArray.d.ts.map +1 -1
- package/dist/src/migrations/BackfillUserRolesArray.js +8 -5
- package/dist/src/migrations/BackfillUserRolesArray.js.map +1 -1
- package/dist/src/migrations/RetireLegacyUserRolesColumn.d.ts +42 -0
- package/dist/src/migrations/RetireLegacyUserRolesColumn.d.ts.map +1 -0
- package/dist/src/migrations/RetireLegacyUserRolesColumn.js +136 -0
- package/dist/src/migrations/RetireLegacyUserRolesColumn.js.map +1 -0
- package/dist/src/services/Roles.d.ts +4 -3
- package/dist/src/services/Roles.d.ts.map +1 -1
- package/dist/src/services/Roles.js +3 -3
- package/dist/src/services/Roles.js.map +1 -1
- package/dist/test/BackfillUserRolesArray.integration.test.js +174 -9
- package/dist/test/BackfillUserRolesArray.integration.test.js.map +1 -1
- package/dist/test/Roles.integration.test.js +71 -0
- package/dist/test/Roles.integration.test.js.map +1 -1
- package/generated/index.ts +3 -1
- package/package.json +5 -5
- package/src/migrations/BackfillUserRolesArray.ts +8 -5
- package/src/migrations/RetireLegacyUserRolesColumn.ts +66 -0
- package/src/services/Roles.ts +12 -6
- package/test/BackfillUserRolesArray.integration.test.ts +79 -5
- package/test/Roles.integration.test.ts +42 -1
|
@@ -43,12 +43,15 @@ var logger_1 = require("@proteinjs/logger");
|
|
|
43
43
|
/**
|
|
44
44
|
* Cutover for `user.roles`: comma-separated free text (legacy `roles` STRING(255) column) → the
|
|
45
45
|
* typed array `role_list` column. Spanner cannot retype a column in place, so the change is
|
|
46
|
-
*
|
|
47
|
-
* (`UserTable.roles` now reads/writes `role_list
|
|
48
|
-
*
|
|
46
|
+
* four-part: the new column (added by schema sync at boot), THIS backfill, the code cutover
|
|
47
|
+
* (`UserTable.roles` now reads/writes `role_list`), and RetireLegacyUserRolesColumn, which NULLs
|
|
48
|
+
* the legacy cells once this backfill has carried them over.
|
|
49
49
|
*
|
|
50
|
-
* Reads the legacy column via raw SQL — it
|
|
51
|
-
*
|
|
50
|
+
* Reads the legacy column via raw SQL — undeclared, it has no column the ORM writes or queries
|
|
51
|
+
* by; what the ORM DOES do with it is read it as part of every row (a stored key under the
|
|
52
|
+
* property's own name, `roles`): the row reader seats cells by declared column name alone, so the
|
|
53
|
+
* cell is omitted and `role_list` lands — the suite beside this migration reads exactly that shape
|
|
54
|
+
* through the ORM. Writes ride the ORM so `role_list` serialization has exactly one owner.
|
|
52
55
|
* Parsing normalizes what free text accumulated: trim, drop empties, dedupe.
|
|
53
56
|
*
|
|
54
57
|
* Idempotent and safe everywhere: rows already carrying a `role_list` value are skipped (a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackfillUserRolesArray.js","sourceRoot":"","sources":["../../../src/migrations/BackfillUserRolesArray.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAqG;AACrG,wCAAyC;AACzC,4CAA2C;AAE3C
|
|
1
|
+
{"version":3,"file":"BackfillUserRolesArray.js","sourceRoot":"","sources":["../../../src/migrations/BackfillUserRolesArray.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAqG;AACrG,wCAAyC;AACzC,4CAA2C;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH;IAAA;QAAA,iBAiDC;QAhDC,UAAK,GAAG,WAAQ,CAAC,SAAS,CAAC;QAC3B,WAAM,GAAG;YACP,EAAE,EAAE,sCAAsC;YAC1C,WAAW,EAAE,oFAAoF;YACjG,GAAG,EAAE;;;;;4BACG,MAAM,GAAG,IAAI,eAAM,CAAC,E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aAAM,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,EAAA;;4BAAnD,SAAmD,CAAC;4BACpD,UAAU,EAAE,CAAC;;;4BAVG,IAAI,CAAA;;;4BAatB,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,EAAE,UAAU,YAAA,EAAE,EAAE,CAAC,CAAC;4BACvE,sBAAO,EAAE,UAAU,YAAA,EAAE,EAAC;;;4BAEtB,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,8BAA8B,EAAE,GAAG,EAAE,EAAE,KAAK,SAAA,EAAE,EAAE,CAAC,CAAC;4BAC1E,MAAM,OAAK,CAAC;;;;iBAEf;SACF,CAAC;IACJ,CAAC;IAAD,6BAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,wDAAsB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Migration, SourceRecordLoader } from '@proteinjs/db';
|
|
2
|
+
/**
|
|
3
|
+
* Retires the legacy `user.roles` text column's data. The cutover to the typed `role_list` array
|
|
4
|
+
* (BackfillUserRolesArray) left the old comma-text column physically present and undeclared, its
|
|
5
|
+
* cells intact on every pre-cutover row: a stored key that is also the property's name (`roles`),
|
|
6
|
+
* riding every read of the table. The row reader seats a cell by its declared column name alone
|
|
7
|
+
* (@proteinjs/db ≥ 1.55.0), so the cell is inert — but data no declared column owns has no
|
|
8
|
+
* business on the row. This NULLs it wherever the typed column already carries the roles, or the
|
|
9
|
+
* legacy cell holds nothing to carry (the empty string a pre-cutover signup wrote).
|
|
10
|
+
*
|
|
11
|
+
* Never a legacy value the backfill has not consumed: a row with legacy text and no `role_list`
|
|
12
|
+
* is left for BackfillUserRolesArray — this migration cannot run ahead of it by construction.
|
|
13
|
+
*
|
|
14
|
+
* Idempotent by shape: a NULLed cell no longer matches. Automated (the deploy-gated series); the
|
|
15
|
+
* column itself goes in a later `manual` migration (a destructive contraction), once every
|
|
16
|
+
* environment reads zero legacy cells. Raw SQL through the driver on both sides, as the backfill
|
|
17
|
+
* reads it: the column is undeclared, so the ORM neither reads nor writes it. A database whose
|
|
18
|
+
* user table never had the column (a fresh install) is a clean no-op.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RetireLegacyUserRolesColumn implements SourceRecordLoader<Migration> {
|
|
21
|
+
table: import("@proteinjs/db").Table<Migration>;
|
|
22
|
+
record: {
|
|
23
|
+
id: string;
|
|
24
|
+
description: string;
|
|
25
|
+
estimate: () => Promise<{
|
|
26
|
+
units: number;
|
|
27
|
+
unit: string;
|
|
28
|
+
note: string;
|
|
29
|
+
} | {
|
|
30
|
+
units: number;
|
|
31
|
+
unit: string;
|
|
32
|
+
note?: undefined;
|
|
33
|
+
}>;
|
|
34
|
+
run: () => Promise<{
|
|
35
|
+
retired: number;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
/** The cells this migration may NULL: a legacy value the typed column already carries, or nothing at all. */
|
|
39
|
+
private retirableCells;
|
|
40
|
+
private legacyColumnExists;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=RetireLegacyUserRolesColumn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetireLegacyUserRolesColumn.d.ts","sourceRoot":"","sources":["../../../src/migrations/RetireLegacyUserRolesColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,SAAS,EAAE,kBAAkB,EAAsB,MAAM,eAAe,CAAC;AAItF;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,2BAA4B,YAAW,kBAAkB,CAAC,SAAS,CAAC;IAC/E,KAAK,2CAAsB;IAC3B,MAAM;;;;;;;;;;;;;;;MA0BJ;IAEF,6GAA6G;IAC7G,OAAO,CAAC,cAAc;YAIR,kBAAkB;CAQjC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.RetireLegacyUserRolesColumn = void 0;
|
|
40
|
+
var db_1 = require("@proteinjs/db");
|
|
41
|
+
var user_1 = require("@proteinjs/user");
|
|
42
|
+
var logger_1 = require("@proteinjs/logger");
|
|
43
|
+
/**
|
|
44
|
+
* Retires the legacy `user.roles` text column's data. The cutover to the typed `role_list` array
|
|
45
|
+
* (BackfillUserRolesArray) left the old comma-text column physically present and undeclared, its
|
|
46
|
+
* cells intact on every pre-cutover row: a stored key that is also the property's name (`roles`),
|
|
47
|
+
* riding every read of the table. The row reader seats a cell by its declared column name alone
|
|
48
|
+
* (@proteinjs/db ≥ 1.55.0), so the cell is inert — but data no declared column owns has no
|
|
49
|
+
* business on the row. This NULLs it wherever the typed column already carries the roles, or the
|
|
50
|
+
* legacy cell holds nothing to carry (the empty string a pre-cutover signup wrote).
|
|
51
|
+
*
|
|
52
|
+
* Never a legacy value the backfill has not consumed: a row with legacy text and no `role_list`
|
|
53
|
+
* is left for BackfillUserRolesArray — this migration cannot run ahead of it by construction.
|
|
54
|
+
*
|
|
55
|
+
* Idempotent by shape: a NULLed cell no longer matches. Automated (the deploy-gated series); the
|
|
56
|
+
* column itself goes in a later `manual` migration (a destructive contraction), once every
|
|
57
|
+
* environment reads zero legacy cells. Raw SQL through the driver on both sides, as the backfill
|
|
58
|
+
* reads it: the column is undeclared, so the ORM neither reads nor writes it. A database whose
|
|
59
|
+
* user table never had the column (a fresh install) is a clean no-op.
|
|
60
|
+
*/
|
|
61
|
+
var RetireLegacyUserRolesColumn = /** @class */ (function () {
|
|
62
|
+
function RetireLegacyUserRolesColumn() {
|
|
63
|
+
var _this = this;
|
|
64
|
+
this.table = db_1.tables.Migration;
|
|
65
|
+
this.record = {
|
|
66
|
+
id: '2f6c0b9e-9c7a-4e0d-8f1b-5a3d7c2e9b41',
|
|
67
|
+
description: "Retire the legacy comma-text user.roles column's cells once role_list carries the roles",
|
|
68
|
+
estimate: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
+
var counted;
|
|
70
|
+
var _this = this;
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return __generator(this, function (_c) {
|
|
73
|
+
switch (_c.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, this.legacyColumnExists()];
|
|
75
|
+
case 1:
|
|
76
|
+
if (!(_c.sent())) {
|
|
77
|
+
return [2 /*return*/, { units: 0, unit: 'rows', note: 'no legacy roles column on the user table' }];
|
|
78
|
+
}
|
|
79
|
+
return [4 /*yield*/, db_1.Db.getDefaultDbDriver().runQuery(function () { return ({
|
|
80
|
+
sql: "SELECT COUNT(*) AS pending FROM ".concat(user_1.tables.User.name, " WHERE ").concat(_this.retirableCells()),
|
|
81
|
+
}); })];
|
|
82
|
+
case 2:
|
|
83
|
+
counted = (_c.sent());
|
|
84
|
+
return [2 /*return*/, { units: Number((_b = (_a = counted[0]) === null || _a === void 0 ? void 0 : _a.pending) !== null && _b !== void 0 ? _b : 0), unit: 'rows' }];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}); },
|
|
88
|
+
run: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
89
|
+
var logger, retired;
|
|
90
|
+
var _this = this;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
logger = new logger_1.Logger({ name: this.constructor.name });
|
|
95
|
+
return [4 /*yield*/, this.legacyColumnExists()];
|
|
96
|
+
case 1:
|
|
97
|
+
if (!(_a.sent())) {
|
|
98
|
+
logger.info({ message: "No legacy roles column on ".concat(user_1.tables.User.name, "; nothing to retire") });
|
|
99
|
+
return [2 /*return*/, { retired: 0 }];
|
|
100
|
+
}
|
|
101
|
+
return [4 /*yield*/, db_1.Db.getDefaultDbDriver().runDml(function () { return ({
|
|
102
|
+
sql: "UPDATE ".concat(user_1.tables.User.name, " SET roles = NULL WHERE ").concat(_this.retirableCells()),
|
|
103
|
+
}); })];
|
|
104
|
+
case 2:
|
|
105
|
+
retired = _a.sent();
|
|
106
|
+
logger.info({ message: "Retired legacy user roles cells", obj: { retired: retired } });
|
|
107
|
+
return [2 /*return*/, { retired: retired }];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); },
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** The cells this migration may NULL: a legacy value the typed column already carries, or nothing at all. */
|
|
114
|
+
RetireLegacyUserRolesColumn.prototype.retirableCells = function () {
|
|
115
|
+
return "roles IS NOT NULL AND (role_list IS NOT NULL OR roles = '')";
|
|
116
|
+
};
|
|
117
|
+
RetireLegacyUserRolesColumn.prototype.legacyColumnExists = function () {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var legacyColumn;
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
switch (_a.label) {
|
|
122
|
+
case 0: return [4 /*yield*/, db_1.Db.getDefaultDbDriver().runQuery(function () { return ({
|
|
123
|
+
sql: "SELECT column_name FROM information_schema.columns " +
|
|
124
|
+
"WHERE table_name = '".concat(user_1.tables.User.name, "' AND column_name = 'roles'"),
|
|
125
|
+
}); })];
|
|
126
|
+
case 1:
|
|
127
|
+
legacyColumn = _a.sent();
|
|
128
|
+
return [2 /*return*/, legacyColumn.length > 0];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return RetireLegacyUserRolesColumn;
|
|
134
|
+
}());
|
|
135
|
+
exports.RetireLegacyUserRolesColumn = RetireLegacyUserRolesColumn;
|
|
136
|
+
//# sourceMappingURL=RetireLegacyUserRolesColumn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetireLegacyUserRolesColumn.js","sourceRoot":"","sources":["../../../src/migrations/RetireLegacyUserRolesColumn.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsF;AACtF,wCAAyC;AACzC,4CAA2C;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH;IAAA;QAAA,iBA2CC;QA1CC,UAAK,GAAG,WAAQ,CAAC,SAAS,CAAC;QAC3B,WAAM,GAAG;YACP,EAAE,EAAE,sCAAsC;YAC1C,WAAW,EAAE,yFAAyF;YACtG,QAAQ,EAAE;;;;;;gCACF,qBAAM,IAAI,CAAC,kBAAkB,EAAE,EAAA;;4BAArC,IAAI,CAAC,CAAC,SAA+B,CAAC,EAAE;gCACtC,sBAAO,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0CAA0C,EAAE,EAAC;6BACrF;4BAEgB,qBAAM,OAAE,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,cAAM,OAAA,CAAC;oCAC7D,GAAG,EAAE,0CAAmC,aAAM,CAAC,IAAI,CAAC,IAAI,oBAAU,KAAI,CAAC,cAAc,EAAE,CAAE;iCAC1F,CAAC,EAF4D,CAE5D,CAAC,EAAA;;4BAFG,OAAO,GAAG,CAAC,SAEd,CAAmD;4BACtD,sBAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAA,MAAA,OAAO,CAAC,CAAC,CAAC,0CAAE,OAAO,mCAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAC;;;iBAClE;YACD,GAA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,IA2CC;AA3CY,kEAA2B"}
|
|
@@ -2,9 +2,10 @@ import { RolesService } from '@proteinjs/user';
|
|
|
2
2
|
import { Service } from '@proteinjs/service';
|
|
3
3
|
/**
|
|
4
4
|
* The ONE write path for user roles (the `user.roles` column is service-protected — generic
|
|
5
|
-
* record writes cannot touch it).
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* record writes cannot touch it). A grant is validated against the roles catalog; a revoke takes any
|
|
6
|
+
* string the record holds (a retired role stays removable here, see `changeRole`). Both are audited:
|
|
7
|
+
* the role update and its `role_grant_event` row (actor, target, role, action; `created` is the
|
|
8
|
+
* timestamp) commit in one transaction, so the trail cannot diverge from the grants.
|
|
8
9
|
*
|
|
9
10
|
* Break-glass roles are never granted through the service door — see `changeRole`; revoking one
|
|
10
11
|
* stays allowed. The ONE break-glass grant in code is `bootstrapAdmin`, the dev first-admin door
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Roles.d.ts","sourceRoot":"","sources":["../../../src/services/Roles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA8D,MAAM,iBAAiB,CAAC;AAG3G,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"Roles.d.ts","sourceRoot":"","sources":["../../../src/services/Roles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA8D,MAAM,iBAAiB,CAAC;AAG3G,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;;;;;;;;;;GAeG;AACH,iHAAiH;AACjH,MAAM,MAAM,qBAAqB,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC;AAEpH,qBAAa,KAAM,YAAW,YAAY;IACjC,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAIhD;IAEI,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;;;;;;;;;;OAaG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,cAAc,GAAG,YAAY,CAAC;IAwBvF;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAuCtE,UAAU;IAmFxB,+GAA+G;YACjG,WAAW;CAK1B"}
|
|
@@ -240,7 +240,7 @@ var Roles = /** @class */ (function () {
|
|
|
240
240
|
case 0:
|
|
241
241
|
logger = new logger_1.Logger({ name: "Roles.".concat(action, "Role") });
|
|
242
242
|
entry = user_1.RolesCatalog.getEntry(role);
|
|
243
|
-
if (!entry) {
|
|
243
|
+
if (!entry && action === 'grant') {
|
|
244
244
|
throw new Error("'".concat(role, "' is not a known role. Pick one from the roles catalog."));
|
|
245
245
|
}
|
|
246
246
|
// Break-glass passes every permission check, so no permission-mapped role — including
|
|
@@ -248,7 +248,7 @@ var Roles = /** @class */ (function () {
|
|
|
248
248
|
// in Spanner Studio, by a human, on purpose (and, on a DEV server only, the first-admin door
|
|
249
249
|
// `bootstrapAdmin`). Revoke stays open: de-escalation toward "held by nobody day-to-day"
|
|
250
250
|
// should ride the audited path, not require database access.
|
|
251
|
-
if (entry.breakGlass && action === 'grant') {
|
|
251
|
+
if ((entry === null || entry === void 0 ? void 0 : entry.breakGlass) && action === 'grant') {
|
|
252
252
|
throw new Error("'".concat(role, "' is a break-glass role \u2014 this service refuses to grant it. The only path to ") +
|
|
253
253
|
"break-glass is a manual UPDATE on the user row in Spanner Studio. (Revoking it here " +
|
|
254
254
|
"stays allowed.)");
|
|
@@ -257,7 +257,7 @@ var Roles = /** @class */ (function () {
|
|
|
257
257
|
// 'roles' permission carries — only an admin may hand them out. Server-side and fail-closed:
|
|
258
258
|
// the service door admits 'roles' holders, so this check is what keeps a user-admin from
|
|
259
259
|
// granting such a role. Revoke stays open — the break-glass de-escalation precedent above.
|
|
260
|
-
if (entry.adminGrantOnly && action === 'grant' && !user_1.UserAuth.hasRole('admin')) {
|
|
260
|
+
if ((entry === null || entry === void 0 ? void 0 : entry.adminGrantOnly) && action === 'grant' && !user_1.UserAuth.hasRole('admin')) {
|
|
261
261
|
throw new Error("'".concat(role, "' can only be granted by an admin \u2014 the 'roles' grant does not cover it. ") +
|
|
262
262
|
"(Revoking it here stays allowed.)");
|
|
263
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Roles.js","sourceRoot":"","sources":["../../../src/services/Roles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAmE;AACnE,wCAA2G;AAC3G,4CAA2C;AAC3C,kDAAsD;
|
|
1
|
+
{"version":3,"file":"Roles.js","sourceRoot":"","sources":["../../../src/services/Roles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAmE;AACnE,wCAA2G;AAC3G,4CAA2C;AAC3C,kDAAsD;AAsBtD;IAAA;QACS,oBAAe,GAA+B;YACnD,IAAI,EAAE;gBACJ,UAAU,EAAE,uBAAgB,CAAC,KAAK;aACnC;SACF,CAAC;IAiMJ,CAAC;IA/LO,yBAAS,GAAf,UAAgB,MAAc,EAAE,IAAY;;;;4BAC1C,qBAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,EAAA;;wBAA5C,SAA4C,CAAC;;;;;KAC9C;IAEK,0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injs/user");
|
|
44
44
|
var BackfillUserRolesArray_1 = require("../src/migrations/BackfillUserRolesArray");
|
|
45
|
+
var RetireLegacyUserRolesColumn_1 = require("../src/migrations/RetireLegacyUserRolesColumn");
|
|
45
46
|
/**
|
|
46
|
-
* The user.roles cutover
|
|
47
|
+
* The user.roles cutover migrations against a real Spanner emulator, simulating a deployed
|
|
47
48
|
* database: the user table carries the NEW schema (role_list, added by schema sync) PLUS the
|
|
48
49
|
* legacy comma-string `roles` column with pre-cutover data — exactly the state a deployment is
|
|
49
|
-
* in when the
|
|
50
|
+
* in when the migrations run. Every read below goes through the ORM: what the row reader makes
|
|
51
|
+
* of a row holding BOTH cells — the legacy `roles` (a word, an empty string, NULL) and the typed
|
|
52
|
+
* `role_list` — is the law this suite proves, not a comment's claim.
|
|
50
53
|
*
|
|
51
54
|
* Pinned outcomes:
|
|
52
55
|
* - legacy comma strings land in role_list as normalized arrays (trim, drop empties, dedupe)
|
|
53
|
-
* - empty/NULL legacy values stay untouched (no roles then, no roles now)
|
|
54
|
-
* - rows already carrying role_list are never clobbered (idempotence / post-cutover grants win)
|
|
55
|
-
*
|
|
56
|
+
* - empty/NULL legacy values stay untouched by the backfill (no roles then, no roles now)
|
|
57
|
+
* - rows already carrying role_list are never clobbered (idempotence / post-cutover grants win),
|
|
58
|
+
* and the ORM reads the array beside the stale legacy word
|
|
59
|
+
* - the retirement NULLs every legacy cell the typed column has absorbed — or that held nothing —
|
|
60
|
+
* and never one the backfill has not consumed; the ORM reads the same arrays before and after
|
|
61
|
+
* (a NULL legacy cell beside the array is the shape a row reader seating by property name
|
|
62
|
+
* would blank)
|
|
63
|
+
* - a database that never had the legacy column (fresh install) is a clean no-op for both
|
|
56
64
|
*/
|
|
57
65
|
var spannerDriver = new db_driver_spanner_1.SpannerDriver({
|
|
58
66
|
projectId: 'proteinjs-test',
|
|
@@ -74,6 +82,18 @@ var runMigration = function () { return __awaiter(void 0, void 0, void 0, functi
|
|
|
74
82
|
case 1: return [2 /*return*/, _a.sent()];
|
|
75
83
|
}
|
|
76
84
|
}); }); };
|
|
85
|
+
var runRetirement = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0: return [4 /*yield*/, new RetireLegacyUserRolesColumn_1.RetireLegacyUserRolesColumn().record.run()];
|
|
88
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
89
|
+
}
|
|
90
|
+
}); }); };
|
|
91
|
+
var estimateRetirement = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0: return [4 /*yield*/, new RetireLegacyUserRolesColumn_1.RetireLegacyUserRolesColumn().record.estimate()];
|
|
94
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
95
|
+
}
|
|
96
|
+
}); }); };
|
|
77
97
|
var rawUserInsert = function (id, legacyRoles) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
98
|
var rolesValue;
|
|
79
99
|
return __generator(this, function (_a) {
|
|
@@ -101,6 +121,17 @@ var rawRoleList = function (id) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
101
121
|
}
|
|
102
122
|
});
|
|
103
123
|
}); };
|
|
124
|
+
/** The legacy cell as the database holds it. */
|
|
125
|
+
var rawRoles = function (id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0: return [4 /*yield*/, spannerDriver.runQuery(function () { return ({
|
|
129
|
+
sql: "SELECT roles FROM ".concat(user_1.tables.User.name, " WHERE id = '").concat(id, "'"),
|
|
130
|
+
}); })];
|
|
131
|
+
case 1: return [2 /*return*/, (_a.sent())[0].roles];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}); };
|
|
104
135
|
describe('BackfillUserRolesArray — legacy comma-string roles → typed role_list', function () {
|
|
105
136
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
137
|
return __generator(this, function (_a) {
|
|
@@ -139,18 +170,152 @@ describe('BackfillUserRolesArray — legacy comma-string roles → typed role_li
|
|
|
139
170
|
});
|
|
140
171
|
}); }, 60000);
|
|
141
172
|
it('is a clean no-op on a database that never had the legacy roles column', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
142
|
-
var _a;
|
|
143
|
-
return __generator(this, function (
|
|
144
|
-
switch (
|
|
173
|
+
var _a, _b, _c;
|
|
174
|
+
return __generator(this, function (_d) {
|
|
175
|
+
switch (_d.label) {
|
|
145
176
|
case 0:
|
|
146
177
|
_a = expect;
|
|
147
178
|
return [4 /*yield*/, runMigration()];
|
|
148
179
|
case 1:
|
|
149
|
-
_a.apply(void 0, [
|
|
180
|
+
_a.apply(void 0, [_d.sent()]).toEqual({ backfilled: 0 });
|
|
181
|
+
_b = expect;
|
|
182
|
+
return [4 /*yield*/, runRetirement()];
|
|
183
|
+
case 2:
|
|
184
|
+
_b.apply(void 0, [_d.sent()]).toEqual({ retired: 0 });
|
|
185
|
+
_c = expect;
|
|
186
|
+
return [4 /*yield*/, estimateRetirement()];
|
|
187
|
+
case 3:
|
|
188
|
+
_c.apply(void 0, [_d.sent()]).toMatchObject({ units: 0, unit: 'rows' });
|
|
150
189
|
return [2 /*return*/];
|
|
151
190
|
}
|
|
152
191
|
});
|
|
153
192
|
}); }, 60000);
|
|
193
|
+
it('retires every legacy cell the typed column has absorbed, never one the backfill has not consumed; the ORM reads the same arrays before and after', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
+
var db, granted_1, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, everyone, _o, _p;
|
|
195
|
+
var _q, _r;
|
|
196
|
+
return __generator(this, function (_s) {
|
|
197
|
+
switch (_s.label) {
|
|
198
|
+
case 0: return [4 /*yield*/, spannerDriver.runUpdateSchema("ALTER TABLE ".concat(user_1.tables.User.name, " ADD COLUMN roles STRING(255)"))];
|
|
199
|
+
case 1:
|
|
200
|
+
_s.sent();
|
|
201
|
+
db = (0, db_1.getDbAsSystem)();
|
|
202
|
+
_s.label = 2;
|
|
203
|
+
case 2:
|
|
204
|
+
_s.trys.push([2, , 25, 28]);
|
|
205
|
+
return [4 /*yield*/, rawUserInsert('retire-carried', 'admin')];
|
|
206
|
+
case 3:
|
|
207
|
+
_s.sent();
|
|
208
|
+
return [4 /*yield*/, rawUserInsert('retire-empty', '')];
|
|
209
|
+
case 4:
|
|
210
|
+
_s.sent();
|
|
211
|
+
return [4 /*yield*/, rawUserInsert('retire-null', null)];
|
|
212
|
+
case 5:
|
|
213
|
+
_s.sent();
|
|
214
|
+
// A legacy value the backfill has not consumed yet: role_list NULL, legacy text present.
|
|
215
|
+
return [4 /*yield*/, rawUserInsert('retire-unconsumed', 'ops')];
|
|
216
|
+
case 6:
|
|
217
|
+
// A legacy value the backfill has not consumed yet: role_list NULL, legacy text present.
|
|
218
|
+
_s.sent();
|
|
219
|
+
return [4 /*yield*/, db.insert(user_1.tables.User, {
|
|
220
|
+
name: 'Granted',
|
|
221
|
+
email: 'granted@test.local',
|
|
222
|
+
password: 'test',
|
|
223
|
+
emailVerified: false,
|
|
224
|
+
roles: ['ops', 'dev'],
|
|
225
|
+
})];
|
|
226
|
+
case 7:
|
|
227
|
+
granted_1 = _s.sent();
|
|
228
|
+
return [4 /*yield*/, spannerDriver.runDml(function () { return ({
|
|
229
|
+
sql: "UPDATE ".concat(user_1.tables.User.name, " SET roles = 'admin' WHERE id = '").concat(granted_1.id, "'"),
|
|
230
|
+
}); })];
|
|
231
|
+
case 8:
|
|
232
|
+
_s.sent();
|
|
233
|
+
// Carry the one consumable legacy value over (as the backfill would); leave 'retire-unconsumed' as a later backfill's.
|
|
234
|
+
return [4 /*yield*/, db.update(user_1.tables.User, { id: 'retire-carried', roles: ['admin'] })];
|
|
235
|
+
case 9:
|
|
236
|
+
// Carry the one consumable legacy value over (as the backfill would); leave 'retire-unconsumed' as a later backfill's.
|
|
237
|
+
_s.sent();
|
|
238
|
+
// Before: the ORM reads the arrays beside the legacy cells, whatever they hold.
|
|
239
|
+
_a = expect;
|
|
240
|
+
return [4 /*yield*/, db.get(user_1.tables.User, { id: 'retire-carried' })];
|
|
241
|
+
case 10:
|
|
242
|
+
// Before: the ORM reads the arrays beside the legacy cells, whatever they hold.
|
|
243
|
+
_a.apply(void 0, [(_s.sent()).roles]).toEqual(['admin']);
|
|
244
|
+
_b = expect;
|
|
245
|
+
return [4 /*yield*/, db.get(user_1.tables.User, { id: granted_1.id })];
|
|
246
|
+
case 11:
|
|
247
|
+
_b.apply(void 0, [(_s.sent()).roles]).toEqual(['ops', 'dev']);
|
|
248
|
+
_c = expect;
|
|
249
|
+
return [4 /*yield*/, estimateRetirement()];
|
|
250
|
+
case 12:
|
|
251
|
+
_c.apply(void 0, [_s.sent()]).toMatchObject({ units: 3, unit: 'rows' });
|
|
252
|
+
_d = expect;
|
|
253
|
+
return [4 /*yield*/, runRetirement()];
|
|
254
|
+
case 13:
|
|
255
|
+
_d.apply(void 0, [_s.sent()]).toEqual({ retired: 3 });
|
|
256
|
+
// The retired cells are NULL; the unconsumed legacy value is untouched.
|
|
257
|
+
_e = expect;
|
|
258
|
+
return [4 /*yield*/, rawRoles('retire-carried')];
|
|
259
|
+
case 14:
|
|
260
|
+
// The retired cells are NULL; the unconsumed legacy value is untouched.
|
|
261
|
+
_e.apply(void 0, [_s.sent()]).toBeNull();
|
|
262
|
+
_f = expect;
|
|
263
|
+
return [4 /*yield*/, rawRoles('retire-empty')];
|
|
264
|
+
case 15:
|
|
265
|
+
_f.apply(void 0, [_s.sent()]).toBeNull();
|
|
266
|
+
_g = expect;
|
|
267
|
+
return [4 /*yield*/, rawRoles('retire-null')];
|
|
268
|
+
case 16:
|
|
269
|
+
_g.apply(void 0, [_s.sent()]).toBeNull();
|
|
270
|
+
_h = expect;
|
|
271
|
+
return [4 /*yield*/, rawRoles(granted_1.id)];
|
|
272
|
+
case 17:
|
|
273
|
+
_h.apply(void 0, [_s.sent()]).toBeNull();
|
|
274
|
+
_j = expect;
|
|
275
|
+
return [4 /*yield*/, rawRoles('retire-unconsumed')];
|
|
276
|
+
case 18:
|
|
277
|
+
_j.apply(void 0, [_s.sent()]).toBe('ops');
|
|
278
|
+
_k = expect;
|
|
279
|
+
return [4 /*yield*/, rawRoleList('retire-unconsumed')];
|
|
280
|
+
case 19:
|
|
281
|
+
_k.apply(void 0, [_s.sent()]).toBeNull();
|
|
282
|
+
// After: a NULL legacy cell beside the array — the ORM still reads the array.
|
|
283
|
+
_l = expect;
|
|
284
|
+
return [4 /*yield*/, db.get(user_1.tables.User, { id: 'retire-carried' })];
|
|
285
|
+
case 20:
|
|
286
|
+
// After: a NULL legacy cell beside the array — the ORM still reads the array.
|
|
287
|
+
_l.apply(void 0, [(_s.sent()).roles]).toEqual(['admin']);
|
|
288
|
+
_m = expect;
|
|
289
|
+
return [4 /*yield*/, db.get(user_1.tables.User, { id: granted_1.id })];
|
|
290
|
+
case 21:
|
|
291
|
+
_m.apply(void 0, [(_s.sent()).roles]).toEqual(['ops', 'dev']);
|
|
292
|
+
return [4 /*yield*/, db.query(user_1.tables.User, {})];
|
|
293
|
+
case 22:
|
|
294
|
+
everyone = _s.sent();
|
|
295
|
+
expect((_q = everyone.find(function (user) { return user.id === granted_1.id; })) === null || _q === void 0 ? void 0 : _q.roles).toEqual(['ops', 'dev']);
|
|
296
|
+
expect((_r = everyone.find(function (user) { return user.id === 'retire-carried'; })) === null || _r === void 0 ? void 0 : _r.roles).toEqual(['admin']);
|
|
297
|
+
// Re-run: nothing left to retire.
|
|
298
|
+
_o = expect;
|
|
299
|
+
return [4 /*yield*/, runRetirement()];
|
|
300
|
+
case 23:
|
|
301
|
+
// Re-run: nothing left to retire.
|
|
302
|
+
_o.apply(void 0, [_s.sent()]).toEqual({ retired: 0 });
|
|
303
|
+
_p = expect;
|
|
304
|
+
return [4 /*yield*/, estimateRetirement()];
|
|
305
|
+
case 24:
|
|
306
|
+
_p.apply(void 0, [_s.sent()]).toMatchObject({ units: 0, unit: 'rows' });
|
|
307
|
+
return [3 /*break*/, 28];
|
|
308
|
+
case 25: return [4 /*yield*/, dropTable(user_1.tables.User)];
|
|
309
|
+
case 26:
|
|
310
|
+
_s.sent();
|
|
311
|
+
return [4 /*yield*/, spannerDriver.getTableManager().loadTable(user_1.tables.User)];
|
|
312
|
+
case 27:
|
|
313
|
+
_s.sent();
|
|
314
|
+
return [7 /*endfinally*/];
|
|
315
|
+
case 28: return [2 /*return*/];
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}); }, 120000);
|
|
154
319
|
it('backfills, normalizes, preserves, and re-runs clean on a deployed-shape database', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
320
|
var db, alreadyMigrated, _a, _b, _c, _d, _e, _f, _g, _h;
|
|
156
321
|
return __generator(this, function (_j) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackfillUserRolesArray.integration.test.js","sourceRoot":"","sources":["../../test/BackfillUserRolesArray.integration.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyD;AACzD,kEAA6D;AAC7D,0DAAiG;AACjG,oDAAyD;AACzD,wCAAyC;AACzC,mFAAkF;
|
|
1
|
+
{"version":3,"file":"BackfillUserRolesArray.integration.test.js","sourceRoot":"","sources":["../../test/BackfillUserRolesArray.integration.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyD;AACzD,kEAA6D;AAC7D,0DAAiG;AACjG,oDAAyD;AACzD,wCAAyC;AACzC,mFAAkF;AAClF,6FAA4F;AAE5F;;;;;;;;;;;;;;;;;;GAkBG;AAEH,IAAM,aAAa,GAAG,IAAI,iCAAa,CAAC;IACtC,SAAS,EAAE,gBAAgB;IAC3B,YAAY,EAAE,gBAAgB;IAC9B,YAAY,EAAE,MAAM;CACrB,CAAC,CAAC;AA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