@venizia/ignis 0.0.9-13 → 0.0.9-15

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.
Files changed (86) hide show
  1. package/dist/base/models/enrichers/tz.enricher.d.ts.map +1 -1
  2. package/dist/base/models/enrichers/tz.enricher.js +5 -2
  3. package/dist/base/models/enrichers/tz.enricher.js.map +1 -1
  4. package/dist/base/repositories/core/readable.d.ts.map +1 -1
  5. package/dist/base/repositories/core/readable.js +16 -4
  6. package/dist/base/repositories/core/readable.js.map +1 -1
  7. package/dist/components/auth/authorize/adapters/base-filtered.d.ts +26 -56
  8. package/dist/components/auth/authorize/adapters/base-filtered.d.ts.map +1 -1
  9. package/dist/components/auth/authorize/adapters/base-filtered.js +23 -70
  10. package/dist/components/auth/authorize/adapters/base-filtered.js.map +1 -1
  11. package/dist/components/auth/authorize/adapters/index.d.ts +2 -1
  12. package/dist/components/auth/authorize/adapters/index.d.ts.map +1 -1
  13. package/dist/components/auth/authorize/adapters/index.js +2 -1
  14. package/dist/components/auth/authorize/adapters/index.js.map +1 -1
  15. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts +131 -0
  16. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts.map +1 -0
  17. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js +293 -0
  18. package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js.map +1 -0
  19. package/dist/components/auth/authorize/adapters/types.d.ts +31 -0
  20. package/dist/components/auth/authorize/adapters/types.d.ts.map +1 -0
  21. package/dist/components/auth/authorize/adapters/types.js +3 -0
  22. package/dist/components/auth/authorize/adapters/types.js.map +1 -0
  23. package/dist/components/auth/authorize/common/constants.d.ts +127 -12
  24. package/dist/components/auth/authorize/common/constants.d.ts.map +1 -1
  25. package/dist/components/auth/authorize/common/constants.js +139 -16
  26. package/dist/components/auth/authorize/common/constants.js.map +1 -1
  27. package/dist/components/auth/authorize/common/index.d.ts +2 -0
  28. package/dist/components/auth/authorize/common/index.d.ts.map +1 -1
  29. package/dist/components/auth/authorize/common/index.js +2 -0
  30. package/dist/components/auth/authorize/common/index.js.map +1 -1
  31. package/dist/components/auth/authorize/common/object-match.d.ts +21 -0
  32. package/dist/components/auth/authorize/common/object-match.d.ts.map +1 -0
  33. package/dist/components/auth/authorize/common/object-match.js +33 -0
  34. package/dist/components/auth/authorize/common/object-match.js.map +1 -0
  35. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts +20 -0
  36. package/dist/components/auth/authorize/common/resolve-request-domain.d.ts.map +1 -0
  37. package/dist/components/auth/authorize/common/resolve-request-domain.js +59 -0
  38. package/dist/components/auth/authorize/common/resolve-request-domain.js.map +1 -0
  39. package/dist/components/auth/authorize/common/types.d.ts +65 -22
  40. package/dist/components/auth/authorize/common/types.d.ts.map +1 -1
  41. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts +119 -30
  42. package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
  43. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js +302 -168
  44. package/dist/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
  45. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts +19 -1
  46. package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts.map +1 -1
  47. package/dist/components/auth/authorize/enforcers/enforcer-registry.js +23 -0
  48. package/dist/components/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
  49. package/dist/components/auth/authorize/enforcers/index.d.ts +1 -0
  50. package/dist/components/auth/authorize/enforcers/index.d.ts.map +1 -1
  51. package/dist/components/auth/authorize/enforcers/index.js +1 -0
  52. package/dist/components/auth/authorize/enforcers/index.js.map +1 -1
  53. package/dist/components/auth/authorize/enforcers/models/index.d.ts +2 -0
  54. package/dist/components/auth/authorize/enforcers/models/index.d.ts.map +1 -0
  55. package/dist/components/auth/authorize/{models/abilities → enforcers/models}/index.js +1 -2
  56. package/dist/components/auth/authorize/enforcers/models/index.js.map +1 -0
  57. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts +32 -0
  58. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +1 -0
  59. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js +54 -0
  60. package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js.map +1 -0
  61. package/dist/components/auth/authorize/models/index.d.ts +0 -1
  62. package/dist/components/auth/authorize/models/index.d.ts.map +1 -1
  63. package/dist/components/auth/authorize/models/index.js +0 -1
  64. package/dist/components/auth/authorize/models/index.js.map +1 -1
  65. package/dist/components/auth/authorize/providers/authorization.provider.d.ts.map +1 -1
  66. package/dist/components/auth/authorize/providers/authorization.provider.js +12 -0
  67. package/dist/components/auth/authorize/providers/authorization.provider.js.map +1 -1
  68. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +1 -1
  69. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -1
  70. package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
  71. package/package.json +3 -3
  72. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts +0 -46
  73. package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts.map +0 -1
  74. package/dist/components/auth/authorize/adapters/drizzle-casbin.js +0 -104
  75. package/dist/components/auth/authorize/adapters/drizzle-casbin.js.map +0 -1
  76. package/dist/components/auth/authorize/models/abilities/index.d.ts +0 -3
  77. package/dist/components/auth/authorize/models/abilities/index.d.ts.map +0 -1
  78. package/dist/components/auth/authorize/models/abilities/index.js.map +0 -1
  79. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts +0 -14
  80. package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts.map +0 -1
  81. package/dist/components/auth/authorize/models/abilities/string-action.model.js +0 -23
  82. package/dist/components/auth/authorize/models/abilities/string-action.model.js.map +0 -1
  83. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts +0 -13
  84. package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts.map +0 -1
  85. package/dist/components/auth/authorize/models/abilities/string-resource.model.js +0 -19
  86. package/dist/components/auth/authorize/models/abilities/string-resource.model.js.map +0 -1
@@ -18,14 +18,27 @@ const injectors_1 = require("../../../../base/metadata/injectors");
18
18
  const ignis_helpers_1 = require("@venizia/ignis-helpers");
19
19
  const common_1 = require("../common");
20
20
  // Casbin Authorization Enforcer — wraps casbin (optional peer dep)
21
+ //
22
+ // Each request evaluates on its OWN enforcer borrowed from a BasePoolHelper<Enforcer>. This kills the
23
+ // shared-model concurrency race: a borrowed enforcer is clearPolicy'd + loaded with THIS user's lines +
24
+ // buildRoleLinks'd + enforceSync'd atomically inside the same pool.use callback, and the pool destroys
25
+ // the enforcer on any error (fail-closed). Pooled enforcers are created WITHOUT an adapter (no DB load at
26
+ // warmup); the adapter is only used by the isolated throwaway extractor (extractUserLines).
21
27
  let CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer_1 = class CasbinAuthorizationEnforcer extends ignis_helpers_1.BaseHelper {
22
28
  constructor(options) {
23
29
  super({ scope: CasbinAuthorizationEnforcer_1.name });
24
30
  this.options = options;
25
31
  this.name = CasbinAuthorizationEnforcer_1.name;
26
32
  this.MIN_EXPIRES_IN = 10_000;
27
- this.enforcer = null;
28
- this.inMemoryInvalidationTimer = null;
33
+ this.pool = null;
34
+ this.helper = null;
35
+ // cacheKey → the in-progress line-fetch for that key. Lets concurrent misses for the SAME user
36
+ // share one extraction instead of all hitting the DB (see fetchLinesWithRedisCache).
37
+ this.pendingLineFetches = new Map();
38
+ // Resolved once in configure(): options.normalizePayloadFn / scoped are fixed after configure, so
39
+ // we memoize the payload normalizer instead of rebuilding a closure on every evaluate() (hot path).
40
+ // Stays `null` until configure() runs; resolves to `undefined` when not scoped + no custom fn (3-arg path).
41
+ this.resolvedPayloadFn = null;
29
42
  }
30
43
  // Lifecycle
31
44
  async configure() {
@@ -43,65 +56,75 @@ let CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer_1 = class CasbinAu
43
56
  message: '[CasbinAuthorizationEnforcer] options.model is required.',
44
57
  });
45
58
  }
46
- const model = this.resolveModel({ casbin, model: this.options.model });
59
+ this.helper = casbin.Helper;
60
+ // Memoize the payload normalizer once — options.{normalizePayloadFn,scoped} are fixed after configure(),
61
+ // so evaluate() reads this field instead of rebuilding a closure per request (hot path).
62
+ this.resolvedPayloadFn = this.options.normalizePayloadFn ?? this.defaultScopedPayloadFn();
47
63
  const { cached } = this.options;
48
- this.enforcer = await this.resolveCasbinEnforcer({
49
- casbin,
50
- model,
51
- adapter: this.options.adapter,
52
- cached,
64
+ if (cached.use) {
65
+ this.validateExpiresIn({ expiresIn: cached.options.expiresIn });
66
+ }
67
+ this.pool = new ignis_helpers_1.BasePoolHelper({
68
+ scope: `${CasbinAuthorizationEnforcer_1.name}.Pool`,
69
+ size: this.options.poolSize ?? 16,
70
+ acquireTimeoutMs: this.options.poolAcquireTimeoutMs ?? 5000,
71
+ create: async () => {
72
+ const model = this.resolveModel({ casbin, model: this.options.model });
73
+ // NO adapter → no DB load at warmup. Policies are loaded per-request in evaluate().
74
+ const enforcer = await casbin.newEnforcer(model);
75
+ await this.registerMatchers({ enforcer, casbin });
76
+ this.assertMatcherCompilesSync({ enforcer });
77
+ return enforcer;
78
+ },
53
79
  });
54
- await this.registerDomainMatchingFunction({ casbin });
80
+ await this.pool.warmup();
55
81
  this.logger
56
82
  .for(this.configure.name)
57
- .info('Casbin enforcer initialized (cached: %s, driver: %s)', cached.use, cached.use ? cached.driver : 'none');
83
+ .info('Casbin enforcer pool ready (size: %s, cached: %s)', this.options.poolSize ?? 16, cached.use ? cached.driver : 'none');
58
84
  }
59
85
  destroy() {
60
- if (!this.inMemoryInvalidationTimer) {
61
- return;
62
- }
63
- clearInterval(this.inMemoryInvalidationTimer);
64
- this.inMemoryInvalidationTimer = null;
86
+ this.pool?.destroy().catch(error => {
87
+ this.logger.for(this.destroy.name).warn('Pool destroy failed: %s', error);
88
+ });
65
89
  }
66
- // IAuthorizationEnforcer — public API
67
- async buildRules(opts) {
68
- const { user } = opts;
69
- if (!this.enforcer) {
70
- throw (0, ignis_helpers_1.getError)({
71
- message: '[CasbinAuthorizationEnforcer] Enforcer not initialized. Call configure() first.',
72
- });
90
+ /**
91
+ * Boot-time smoke test for the matcher. casbin compiles the matcher expression LAZILY — not in
92
+ * newEnforcer() or buildRoleLinks(), but on the first enforce — so a broken matcher would otherwise
93
+ * only surface on the first real request (a 500 for a real user). Running one dummy enforceSync here
94
+ * forces that compile at warmup, turning these into a fail-at-boot for an authz component:
95
+ * - matcher syntax errors in the model,
96
+ * - references to functions that registerMatchers() didn't register (e.g. a renamed g-relation),
97
+ * - request arity mismatch (4-token scoped model vs the 3/4 args we pass).
98
+ * Bonus: enforceSync also throws if a matcher func is async — but every func we register is a sync
99
+ * built-in, so that branch is effectively unreachable; the real value is the compile/wiring check above.
100
+ */
101
+ assertMatcherCompilesSync(opts) {
102
+ try {
103
+ if (this.options.isScoped || this.options.normalizePayloadFn) {
104
+ opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup', '::warmup');
105
+ return;
106
+ }
107
+ opts.enforcer.enforceSync('::warmup', '::warmup', '::warmup');
73
108
  }
74
- if (!this.enforcer.loadFilteredPolicy) {
109
+ catch (error) {
75
110
  throw (0, ignis_helpers_1.getError)({
76
- message: '[CasbinAuthorizationEnforcer] Adapter does not support loadFilteredPolicy.',
111
+ message: `[CasbinAuthorizationEnforcer] Matcher smoke test failed at warmup — the model matcher did not compile (check matcher syntax, that every referenced function is registered, and the request arity). ${String(error)}`,
77
112
  });
78
113
  }
114
+ }
115
+ // IAuthorizationEnforcer — public API
116
+ async buildRules(opts) {
117
+ const { user } = opts;
79
118
  const cached = this.options.cached;
80
- if (!cached.use) {
81
- await this.loadPoliciesFromAdapter({ user });
82
- return user;
83
- }
84
- switch (cached.driver) {
85
- case common_1.CasbinEnforcerCachedDrivers.IN_MEMORY: {
86
- await this.loadPoliciesFromAdapter({ user });
87
- break;
88
- }
89
- case common_1.CasbinEnforcerCachedDrivers.REDIS: {
90
- await this.loadPoliciesWithRedisCache({ user, cached });
91
- break;
92
- }
93
- default: {
94
- throw (0, ignis_helpers_1.getError)({
95
- message: `[buildRules] Invalid cached.driver | Valids: [${common_1.CasbinEnforcerCachedDrivers.IN_MEMORY}, ${common_1.CasbinEnforcerCachedDrivers.REDIS}]`,
96
- });
97
- }
98
- }
99
- return user;
119
+ const lines = cached.use
120
+ ? await this.fetchLinesWithRedisCache({ user, cached })
121
+ : await this.extractUserLines({ user });
122
+ return { user, lines };
100
123
  }
101
124
  async evaluate(opts) {
102
- if (!this.enforcer) {
125
+ if (!this.pool) {
103
126
  throw (0, ignis_helpers_1.getError)({
104
- message: '[CasbinAuthorizationEnforcer] Enforcer not initialized. Call configure() first.',
127
+ message: '[CasbinAuthorizationEnforcer] Not configured. Call configure() first.',
105
128
  });
106
129
  }
107
130
  if (!opts.request?.action || !opts.request?.resource) {
@@ -109,76 +132,126 @@ let CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer_1 = class CasbinAu
109
132
  message: '[CasbinAuthorizationEnforcer] request.action and request.resource are required.',
110
133
  });
111
134
  }
112
- const { rules: user, request, context } = opts;
113
- const normalizePayloadFn = this.options.normalizePayloadFn;
114
- let isAllowed;
115
- if (!normalizePayloadFn) {
116
- const subject = `${user.principalType}_${user.userId}`;
117
- isAllowed = this.enforcer.enforceSync(subject, request.resource, request.action);
118
- return isAllowed ? common_1.AuthorizationDecisions.ALLOW : common_1.AuthorizationDecisions.DENY;
119
- }
120
- const normalized = normalizePayloadFn({
121
- user,
122
- action: request.action,
123
- resource: request.resource,
124
- context,
135
+ const { rules, request, context } = opts;
136
+ const { user, lines } = rules;
137
+ return this.pool.use({
138
+ fn: async (enforcer) => {
139
+ // Load THIS user's lines + buildRoleLinks BEFORE any enforceSync on the borrowed enforcer.
140
+ await this.loadPolicyLinesIntoModel({ enforcer, lines });
141
+ const normalizePayloadFn = this.resolvedPayloadFn;
142
+ if (!normalizePayloadFn) {
143
+ const subject = `${user.principalType}_${user.userId}`;
144
+ const isAllowed = this.enforceWithExplain({
145
+ enforcer,
146
+ vals: [subject, String(request.resource), String(request.action)],
147
+ });
148
+ return isAllowed ? common_1.AuthorizationDecisions.ALLOW : common_1.AuthorizationDecisions.DENY;
149
+ }
150
+ const normalized = normalizePayloadFn({
151
+ user,
152
+ action: request.action,
153
+ resource: request.resource,
154
+ context,
155
+ });
156
+ // Domain-aware enforcement: enforceSync(sub, dom, obj, act).
157
+ // In scoped mode the model is 4-token (r = sub, dom, obj, act); a request with no resolvable
158
+ // domain MUST still enforce with a domain — default to SYSTEM_WIDE, never fall through to the
159
+ // 3-arg path (which would shift args against the scoped model and silently misjudge).
160
+ const domain = normalized.domain ??
161
+ request.domain ??
162
+ (this.options.isScoped ? common_1.AuthorizationDomainScopes.SYSTEM_WIDE : undefined);
163
+ const vals = domain
164
+ ? [normalized.subject, domain, normalized.resource, normalized.action]
165
+ : [normalized.subject, normalized.resource, normalized.action];
166
+ const isAllowed = this.enforceWithExplain({ enforcer, vals });
167
+ return isAllowed ? common_1.AuthorizationDecisions.ALLOW : common_1.AuthorizationDecisions.DENY;
168
+ },
125
169
  });
126
- // Domain-aware enforcement: enforceSync(sub, dom, obj, act).
127
- // The arg count MUST match the model's [request_definition]. For a domain model
128
- // (`r = sub, dom, obj, act`) normalizePayloadFn must always return a `domain`; if it returns
129
- // undefined here we fall back to the 3-arg form, which only fits a non-domain model
130
- // (`r = sub, obj, act`). Returning undefined against a 4-arg model would shift the columns
131
- // (r.dom <- resource, r.obj <- action, r.act <- undefined) and silently mis-evaluate.
132
- if (normalized.domain) {
133
- isAllowed = this.enforcer.enforceSync(normalized.subject, normalized.domain, normalized.resource, normalized.action);
170
+ }
171
+ /**
172
+ * Run the matcher synchronously and, on DENY, log WHICH policy rule decided it. enforceExSync returns
173
+ * `[isAllowed, matchedPolicy]` where matchedPolicy is the deciding rule (or `[]` when nothing matched
174
+ * default-deny). The explain index is computed by the effector regardless of this call, so capturing it
175
+ * carries no meaningful cost over enforceSync it just surfaces the reason for a denial to the logs.
176
+ */
177
+ enforceWithExplain(opts) {
178
+ const [isAllowed, matchedPolicy] = opts.enforcer.enforceExSync(...opts.vals);
179
+ if (!isAllowed) {
180
+ this.logger
181
+ .for(this.evaluate.name)
182
+ .info('DENY | request: [%s] | matchedPolicy: %s', opts.vals.join(', '), matchedPolicy.length ? matchedPolicy.join(', ') : '<none — default-deny>');
134
183
  }
135
- else {
136
- isAllowed = this.enforcer.enforceSync(normalized.subject, normalized.resource, normalized.action);
184
+ return isAllowed;
185
+ }
186
+ // Cache management — optional IAuthorizationEnforcer members (on-demand)
187
+ async invalidateUserCache(opts) {
188
+ const cached = this.requireRedisCache();
189
+ const cacheKey = await this.resolveCacheKey({ user: opts.user, cached });
190
+ const invalidatedKeys = await cached.options.connection.client.del(cacheKey);
191
+ this.logger
192
+ .for(this.invalidateUserCache.name)
193
+ .info('Invalidated authz cache | user: %s | key: %s | deleted: %s', opts.user.userId, cacheKey, invalidatedKeys);
194
+ return { invalidatedKeys };
195
+ }
196
+ async rebuildUserCache(opts) {
197
+ const cached = this.requireRedisCache();
198
+ // Resolve the key once: drop the stale entry, then re-cache warm. Extraction runs on an ISOLATED
199
+ // throwaway enforcer (not a serving model), so a concurrent request cannot make us cache another
200
+ // user's policies under this key.
201
+ const cacheKey = await this.resolveCacheKey({ user: opts.user, cached });
202
+ await cached.options.connection.client.del(cacheKey);
203
+ const lines = await this.extractUserLines({ user: opts.user });
204
+ await this.writeCachedPolicyLines({ cacheKey, lines, options: cached.options });
205
+ this.logger
206
+ .for(this.rebuildUserCache.name)
207
+ .info('Rebuilt authz cache | user: %s | key: %s | lines: %s', opts.user.userId, cacheKey, lines.length);
208
+ return { cacheKey, lineCount: lines.length };
209
+ }
210
+ /** Compute the user's cache key and reject an empty result — consistent with the read path. */
211
+ async resolveCacheKey(opts) {
212
+ const cacheKey = await opts.cached.options.keyFn({ user: opts.user });
213
+ if (!cacheKey) {
214
+ throw (0, ignis_helpers_1.getError)({
215
+ statusCode: ignis_helpers_1.HTTP.ResultCodes.RS_4.BadRequest,
216
+ message: '[CasbinAuthorizationEnforcer] keyFn returned an empty cache key.',
217
+ });
137
218
  }
138
- return isAllowed ? common_1.AuthorizationDecisions.ALLOW : common_1.AuthorizationDecisions.DENY;
219
+ return cacheKey;
139
220
  }
140
- // Enforcer & model resolvers
141
- async resolveCasbinEnforcer(opts) {
142
- const { casbin, model, adapter, cached } = opts;
221
+ /** Narrow `options.cached` to the redis variant; cache management is redis-only. */
222
+ requireRedisCache() {
223
+ const { cached } = this.options;
143
224
  if (!cached.use) {
144
- return casbin.newEnforcer(model, adapter);
225
+ throw (0, ignis_helpers_1.getError)({
226
+ message: '[CasbinAuthorizationEnforcer] Cache management requires the redis cache driver, but caching is disabled.',
227
+ });
145
228
  }
146
- switch (cached.driver) {
147
- case common_1.CasbinEnforcerCachedDrivers.IN_MEMORY: {
148
- this.validateExpiresIn({ expiresIn: cached.options.expiresIn });
149
- const enforcer = await casbin.newCachedEnforcer(model, adapter);
150
- this.inMemoryInvalidationTimer = setInterval(() => {
151
- enforcer.invalidateCache();
152
- this.logger.info('[resolveCasbinEnforcer] Enforcer cache INVALIDATED | name: %s', this.name);
153
- }, cached.options.expiresIn);
154
- return enforcer;
155
- }
156
- case common_1.CasbinEnforcerCachedDrivers.REDIS: {
157
- this.validateExpiresIn({ expiresIn: cached.options.expiresIn });
158
- return casbin.newEnforcer(model, adapter);
159
- }
160
- default: {
229
+ return cached;
230
+ }
231
+ // Matchers & model resolvers
232
+ async registerMatchers(opts) {
233
+ const { enforcer, casbin } = opts;
234
+ const { domainMatching, isScoped } = this.options;
235
+ if (domainMatching) {
236
+ if (!enforcer.getNamedRoleManager(domainMatching.roleDefinition)) {
161
237
  throw (0, ignis_helpers_1.getError)({
162
- message: `[resolveCasbinEnforcer] Invalid cached.driver | Valids: [${common_1.CasbinEnforcerCachedDrivers.IN_MEMORY}, ${common_1.CasbinEnforcerCachedDrivers.REDIS}]`,
238
+ message: `[registerMatchers] Role definition "${domainMatching.roleDefinition}" is not declared in the Casbin model. Declare it under [role_definition] (e.g. \`g = _, _, _\`) before enabling domainMatching.`,
163
239
  });
164
240
  }
241
+ const matchFn = this.resolveDomainMatchingFn({ casbin, name: domainMatching.fn });
242
+ await enforcer.addNamedDomainMatchingFunc(domainMatching.roleDefinition, matchFn);
165
243
  }
166
- }
167
- async registerDomainMatchingFunction(opts) {
168
- const { domainMatching } = this.options;
169
- if (!domainMatching) {
170
- return;
171
- }
172
- if (!this.enforcer) {
173
- throw (0, ignis_helpers_1.getError)({
174
- message: '[registerDomainMatchingFunc] Enforcer not initialized. Call configure() first.',
175
- });
176
- }
177
- if (!this.enforcer.getNamedRoleManager(domainMatching.roleDefinition)) {
178
- throw (0, ignis_helpers_1.getError)({
179
- message: `[registerDomainMatchingFunc] Role definition "${domainMatching.roleDefinition}" is not declared in the Casbin model. Declare it under [role_definition] (e.g. \`g = _, _, _\`) before enabling domainMatching.`,
180
- });
244
+ if (isScoped) {
245
+ await enforcer.addNamedDomainMatchingFunc(common_1.CasbinRuleVariants.G, casbin.Util.keyMatchFunc);
246
+ await enforcer.addFunction('objectMatch', common_1.objectMatch);
247
+ // objectMatch is the matching func for the resource hierarchy relation (g4 under the
248
+ // request-tuple numbering); reference the constant so it tracks any future renumber.
249
+ await enforcer.addNamedMatchingFunc(common_1.AuthorizationPolicyVariants.RESOURCE_INHERITS.rule, common_1.objectMatch);
181
250
  }
251
+ await enforcer.buildRoleLinks();
252
+ }
253
+ /** Map a CasbinDomainMatchingFunctions value to casbin's Util.*Func matcher. */
254
+ resolveDomainMatchingFn(opts) {
182
255
  // `Util` is casbin's bag of built-in comparison functions. Each `*Func` takes two strings
183
256
  // (the request value, the stored/policy value) and returns whether they "match":
184
257
  // keyMatchFunc — `*` is the only wildcard. keyMatch("anything","*")=true; exact otherwise.
@@ -189,40 +262,42 @@ let CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer_1 = class CasbinAu
189
262
  // keyMatch4Func — `{param}` with repeated-name equality checks.
190
263
  // regexMatchFunc — treats the stored value as a full regular expression.
191
264
  const { Util } = opts.casbin;
192
- let matchFn;
193
- switch (domainMatching.fn) {
265
+ switch (opts.name) {
194
266
  case common_1.CasbinDomainMatchingFunctions.KEY_MATCH: {
195
- matchFn = Util.keyMatchFunc;
196
- break;
267
+ return Util.keyMatchFunc;
197
268
  }
198
269
  case common_1.CasbinDomainMatchingFunctions.KEY_MATCH_2: {
199
- matchFn = Util.keyMatch2Func;
200
- break;
270
+ return Util.keyMatch2Func;
201
271
  }
202
272
  case common_1.CasbinDomainMatchingFunctions.KEY_MATCH_3: {
203
- matchFn = Util.keyMatch3Func;
204
- break;
273
+ return Util.keyMatch3Func;
205
274
  }
206
275
  case common_1.CasbinDomainMatchingFunctions.KEY_MATCH_4: {
207
- matchFn = Util.keyMatch4Func;
208
- break;
276
+ return Util.keyMatch4Func;
209
277
  }
210
278
  case common_1.CasbinDomainMatchingFunctions.REGEX_MATCH: {
211
- matchFn = Util.regexMatchFunc;
212
- break;
279
+ return Util.regexMatchFunc;
213
280
  }
214
281
  default: {
215
282
  throw (0, ignis_helpers_1.getError)({
216
- message: `[registerDomainMatchingFunc] Unsupported func: ${domainMatching.fn} | Valids: [${[...common_1.CasbinDomainMatchingFunctions.SCHEME_SET].join(', ')}]`,
283
+ message: `[resolveDomainMatchingFn] Unsupported func: ${opts.name} | Valids: [${[...common_1.CasbinDomainMatchingFunctions.SCHEME_SET].join(', ')}]`,
217
284
  });
218
285
  }
219
286
  }
220
- await this.enforcer.addNamedDomainMatchingFunc(domainMatching.roleDefinition, matchFn);
221
- // buildRoleLinks(): (re)computes the in-memory role-inheritance graph from the grouping policies.
222
- await this.enforcer.buildRoleLinks();
223
- this.logger
224
- .for(this.configure.name)
225
- .info('Casbin domain matching func registered | roleDefinition: %s, func: %s', domainMatching.roleDefinition, domainMatching.fn);
287
+ }
288
+ /** Default (sub,dom,obj,act) payload for the scoped model; domain comes from request.domain. */
289
+ defaultScopedPayloadFn() {
290
+ if (!this.options.isScoped) {
291
+ return undefined;
292
+ }
293
+ return (opts) => {
294
+ // No domain here — evaluate() fills it from request.domain (set by the provider).
295
+ return {
296
+ subject: `${opts.user.principalType}_${opts.user.userId}`,
297
+ resource: String(opts.resource),
298
+ action: String(opts.action),
299
+ };
300
+ };
226
301
  }
227
302
  resolveModel(opts) {
228
303
  const { casbin, model } = opts;
@@ -249,67 +324,126 @@ let CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer_1 = class CasbinAu
249
324
  });
250
325
  }
251
326
  // Policy loading internals
252
- async loadPoliciesFromAdapter(opts) {
253
- if (!this.enforcer) {
254
- throw (0, ignis_helpers_1.getError)({
255
- message: '[loadPoliciesFromAdapter] Invalid state of enforcer | Enforcer is not initialized!',
256
- });
327
+ /**
328
+ * Fetch the user's policy lines, collapsing concurrent cache misses for the same key onto a single
329
+ * extraction (via `pendingLineFetches`) instead of letting every request hit the DB at once.
330
+ * Note: best-effort two misses can both get past the cache read before either records its fetch
331
+ * in the map, so both extract once (benign: per-user lines are identical). It collapses the common
332
+ * case; the fast cache-hit path stays OUTSIDE the map to avoid needless contention.
333
+ */
334
+ async fetchLinesWithRedisCache(opts) {
335
+ const { user, cached } = opts;
336
+ const cacheKey = await this.resolveCacheKey({ user, cached });
337
+ const redisClient = cached.options.connection.client;
338
+ // Cache hit — Redis owns expiry (PX on write), so a present key is fresh by definition.
339
+ // A corrupted/legacy entry must NOT 500 the request: discard it and fall through to refetch.
340
+ const raw = await redisClient.get(cacheKey);
341
+ if (raw) {
342
+ const lines = this.parseCachedPolicyLines({ raw, cacheKey });
343
+ if (lines) {
344
+ return lines;
345
+ }
346
+ }
347
+ const existing = this.pendingLineFetches.get(cacheKey);
348
+ if (existing) {
349
+ return existing;
257
350
  }
258
- await this.enforcer.loadFilteredPolicy({
259
- principalType: opts.user.principalType,
260
- principalValue: opts.user.userId,
351
+ // Cache miss (or discarded corrupt entry) — extract from an ISOLATED enforcer so a concurrent
352
+ // load cannot contaminate the cache, persist it, then return the lines for THIS request.
353
+ const task = async () => {
354
+ const lines = await this.extractUserLines({ user });
355
+ await this.writeCachedPolicyLines({ cacheKey, lines, options: cached.options });
356
+ return lines;
357
+ };
358
+ const promise = task().finally(() => {
359
+ this.pendingLineFetches.delete(cacheKey);
261
360
  });
361
+ this.pendingLineFetches.set(cacheKey, promise);
362
+ return promise;
262
363
  }
263
- async loadPoliciesWithRedisCache(opts) {
264
- const logger = this.logger.for(this.loadPoliciesWithRedisCache.name);
265
- const { user, cached: { options }, } = opts;
266
- const cacheKey = await options.keyFn({ user });
267
- if (!cacheKey) {
268
- throw (0, ignis_helpers_1.getError)({
269
- statusCode: ignis_helpers_1.HTTP.ResultCodes.RS_4.BadRequest,
270
- message: '[loadPoliciesWithRedisCache] Invalid cachedKey to start validate user authorization!',
271
- });
364
+ /** Single source of truth for the Redis cache encoding. Used by miss-path and rebuild. */
365
+ async writeCachedPolicyLines(opts) {
366
+ await opts.options.connection.client.set(opts.cacheKey, JSON.stringify(opts.lines), 'PX', opts.options.expiresIn);
367
+ }
368
+ /** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */
369
+ parseCachedPolicyLines(opts) {
370
+ try {
371
+ const parsed = JSON.parse(opts.raw);
372
+ if (!Array.isArray(parsed) || parsed.some(line => typeof line !== 'string')) {
373
+ throw (0, ignis_helpers_1.getError)({
374
+ message: '[CasbinAuthorizationEnforcer] Cached payload is not an array of policy lines.',
375
+ });
376
+ }
377
+ return parsed;
272
378
  }
273
- const redisClient = options.connection.client;
274
- // Cache hit — load lines directly into model
275
- const cachedData = await redisClient.get(cacheKey);
276
- if (cachedData) {
277
- const lines = JSON.parse(cachedData);
278
- await this.loadPolicyLinesIntoModel({ lines });
279
- logger.info('Loaded CACHED Policies into model | user: %s', user.userId);
280
- return;
379
+ catch (error) {
380
+ this.logger
381
+ .for(this.parseCachedPolicyLines.name)
382
+ .warn('Discarding corrupted authz cache entry | key: %s | error: %s', opts.cacheKey, error);
383
+ return null;
281
384
  }
282
- // Cache miss — load from adapter, extract lines, cache in Redis
283
- await this.loadPoliciesFromAdapter({ user });
284
- const lines = await this.extractPolicyLines();
285
- await redisClient.set(cacheKey, JSON.stringify(lines), 'PX', options.expiresIn);
286
- logger.info('Loaded ADAPTER + CACHED Policies into model | user: %s', user.userId);
287
385
  }
288
- async extractPolicyLines() {
289
- if (!this.enforcer) {
386
+ /**
387
+ * Extract a user's policy lines from an ISOLATED throwaway enforcer (its own model + the adapter),
388
+ * never a pooled serving enforcer. This is the core of the anti-poisoning design: concurrent requests
389
+ * on pooled enforcers can't change what we cache for this user. Used by buildRules + rebuild.
390
+ */
391
+ async extractUserLines(opts) {
392
+ const casbin = await import('casbin');
393
+ const model = this.resolveModel({ casbin, model: this.options.model });
394
+ const loader = await casbin.newEnforcer(model, this.options.adapter);
395
+ if (!loader.loadFilteredPolicy) {
290
396
  throw (0, ignis_helpers_1.getError)({
291
- message: '[extractPolicyLines] Invalid state of enforcer | Enforcer is not initialized!',
397
+ message: '[extractUserLines] Adapter does not support loadFilteredPolicy.',
292
398
  });
293
399
  }
294
- const pRules = await this.enforcer.getPolicy();
295
- const ps = pRules.map(r => [common_1.CasbinRuleVariants.P, ...r].join(', '));
296
- const gRules = await this.enforcer.getGroupingPolicy();
297
- const gs = gRules.map(r => [common_1.CasbinRuleVariants.G, ...r].join(', '));
298
- return [...ps, ...gs];
400
+ await loader.loadFilteredPolicy({
401
+ principal: { type: opts.user.principalType, id: opts.user.userId },
402
+ });
403
+ return this.extractLinesFrom(loader);
404
+ }
405
+ /**
406
+ * Serialize ALL policy + grouping rule types of an enforcer's model back into casbin lines.
407
+ * Covers every p-type (p, p2, …) and g-type (g, g2, g3, g4, g5, …) — not just `p`/`g` — so the
408
+ * cached payload is complete for the scoped model (resource/action/domain hierarchies + membership).
409
+ * Reads stored rules (independent of role-link matching funcs), so the loader needs none registered.
410
+ */
411
+ async extractLinesFrom(enforcer) {
412
+ const model = enforcer.getModel();
413
+ const lines = [];
414
+ const policyTypes = model.model.get(common_1.CasbinRuleVariants.P);
415
+ if (policyTypes) {
416
+ for (const ptype of policyTypes.keys()) {
417
+ const rules = await enforcer.getNamedPolicy(ptype);
418
+ for (const rule of rules) {
419
+ lines.push([ptype, ...rule].join(', '));
420
+ }
421
+ }
422
+ }
423
+ const groupingTypes = model.model.get(common_1.CasbinRuleVariants.G);
424
+ if (groupingTypes) {
425
+ for (const gtype of groupingTypes.keys()) {
426
+ const rules = await enforcer.getNamedGroupingPolicy(gtype);
427
+ for (const rule of rules) {
428
+ lines.push([gtype, ...rule].join(', '));
429
+ }
430
+ }
431
+ }
432
+ return lines;
299
433
  }
434
+ /** Atomically reset a borrowed enforcer's model to exactly `lines` + rebuild role links. */
300
435
  async loadPolicyLinesIntoModel(opts) {
301
- if (!this.enforcer) {
436
+ if (!this.helper) {
302
437
  throw (0, ignis_helpers_1.getError)({
303
- message: '[loadPolicyLinesIntoModel] Enforcer not initialized. Call configure() first.',
438
+ message: '[loadPolicyLinesIntoModel] Not configured. Call configure() first.',
304
439
  });
305
440
  }
306
- const { Helper } = await import('casbin');
307
- const model = this.enforcer.getModel();
441
+ const model = opts.enforcer.getModel();
308
442
  model.clearPolicy();
309
443
  for (const line of opts.lines) {
310
- Helper.loadPolicyLine(line, model);
444
+ this.helper.loadPolicyLine(line, model);
311
445
  }
312
- await this.enforcer.buildRoleLinks();
446
+ await opts.enforcer.buildRoleLinks();
313
447
  }
314
448
  };
315
449
  exports.CasbinAuthorizationEnforcer = CasbinAuthorizationEnforcer;
@@ -1 +1 @@
1
- {"version":3,"file":"casbin.enforcer.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yDAAmD;AACnD,0DAA+E;AAO/E,sCAcmB;AAEnB,mEAAmE;AAEnE,IAAa,2BAA2B,mCA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pB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IACvC,CAAC;CACF,CAAA;AAxZY,kEAA2B;sCAA3B,2BAA2B;IAenC,WAAA,IAAA,kBAAM,EAAC,EAAE,GAAG,EAAE,6BAAoB,CAAC,eAAe,CAAC,mCAA0B,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;;GAfhF,2BAA2B,CAwZvC"}
1
+ {"version":3,"file":"casbin.enforcer.js","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yDAAmD;AACnD,0DAA+F;AAG/F,sCAkBmB;AAUnB,mEAAmE;AACnE,EAAE;AACF,sGAAsG;AACtG,wGAAwG;AACxG,uGAAuG;AACvG,0GAA0G;AAC1G,4FAA4F;AAE5F,IAAa,2BAA2B,mCAAxC,MAAa,2BAKX,SAAQ,0BAAU;IAiBlB,YAEE,OAA8D;QAE9D,KAAK,CAAC,EAAE,KAAK,EAAE,6BAA2B,CAAC,IAAI,EAAE,CAAC,CAAC;QAF3C,YAAO,GAAP,OAAO,CAA+C;QAhBhE,SAAI,GAAG,6BAA2B,CAAC,IAAI,CAAC;QACvB,mBAAc,GAAG,MAAM,CAAC;QAEjC,SAAI,GAAkD,IAAI,CAAC;QAC3D,WAAM,GAAuC,IAAI,CAAC;QAC1D,+FAA+F;QAC/F,qFAAqF;QACpE,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAE3E,kGAAkG;QAClG,oGAAoG;QACpG,4GAA4G;QACpG,sBAAiB,GAA0D,IAAI,CAAC;IAOxF,CAAC;IAED,YAAY;IAEZ,KAAK,CAAC,SAAS;QACb,IAAI,MAA+B,CAAC;QAEpC,IAAI,CAAC;YAC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