@venizia/ignis 0.0.9-2 → 0.0.9-21
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/README.md +2 -2
- package/dist/base/metadata/persistents.d.ts.map +1 -1
- package/dist/base/metadata/persistents.js +6 -0
- package/dist/base/metadata/persistents.js.map +1 -1
- package/dist/base/middlewares/app-error/app-error.middleware.d.ts +15 -0
- package/dist/base/middlewares/app-error/app-error.middleware.d.ts.map +1 -0
- package/dist/base/middlewares/app-error/app-error.middleware.js +81 -0
- package/dist/base/middlewares/app-error/app-error.middleware.js.map +1 -0
- package/dist/base/middlewares/app-error/database.handler.d.ts +20 -0
- package/dist/base/middlewares/app-error/database.handler.d.ts.map +1 -0
- package/dist/base/middlewares/app-error/database.handler.js +55 -0
- package/dist/base/middlewares/app-error/database.handler.js.map +1 -0
- package/dist/base/middlewares/app-error/definition.d.ts +59 -0
- package/dist/base/middlewares/app-error/definition.d.ts.map +1 -0
- package/dist/base/middlewares/app-error/definition.js +98 -0
- package/dist/base/middlewares/app-error/definition.js.map +1 -0
- package/dist/base/middlewares/app-error/index.d.ts +2 -0
- package/dist/base/middlewares/app-error/index.d.ts.map +1 -0
- package/dist/{components/auth/authorize/models/abilities → base/middlewares/app-error}/index.js +1 -2
- package/dist/base/middlewares/app-error/index.js.map +1 -0
- package/dist/base/middlewares/app-error/types.d.ts +18 -0
- package/dist/base/middlewares/app-error/types.d.ts.map +1 -0
- package/dist/base/middlewares/app-error/types.js +3 -0
- package/dist/base/middlewares/app-error/types.js.map +1 -0
- package/dist/base/middlewares/app-error/zod.handler.d.ts +28 -0
- package/dist/base/middlewares/app-error/zod.handler.d.ts.map +1 -0
- package/dist/base/middlewares/app-error/zod.handler.js +64 -0
- package/dist/base/middlewares/app-error/zod.handler.js.map +1 -0
- package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts.map +1 -0
- package/dist/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -0
- package/dist/base/middlewares/emoji-favicon/index.d.ts +2 -0
- package/dist/base/middlewares/emoji-favicon/index.d.ts.map +1 -0
- package/dist/base/middlewares/emoji-favicon/index.js +18 -0
- package/dist/base/middlewares/emoji-favicon/index.js.map +1 -0
- package/dist/base/middlewares/index.d.ts +4 -4
- package/dist/base/middlewares/index.d.ts.map +1 -1
- package/dist/base/middlewares/index.js +4 -4
- package/dist/base/middlewares/index.js.map +1 -1
- package/dist/base/middlewares/not-found/index.d.ts +2 -0
- package/dist/base/middlewares/not-found/index.d.ts.map +1 -0
- package/dist/base/middlewares/not-found/index.js +18 -0
- package/dist/base/middlewares/not-found/index.js.map +1 -0
- package/dist/base/middlewares/{not-found.middleware.d.ts → not-found/not-found.middleware.d.ts} +0 -1
- package/dist/base/middlewares/not-found/not-found.middleware.d.ts.map +1 -0
- package/dist/base/middlewares/{not-found.middleware.js → not-found/not-found.middleware.js} +2 -3
- package/dist/base/middlewares/{not-found.middleware.js.map → not-found/not-found.middleware.js.map} +1 -1
- package/dist/base/middlewares/request-spy/index.d.ts +2 -0
- package/dist/base/middlewares/request-spy/index.d.ts.map +1 -0
- package/dist/base/middlewares/request-spy/index.js +18 -0
- package/dist/base/middlewares/request-spy/index.js.map +1 -0
- package/dist/base/middlewares/{request-spy.middleware.d.ts → request-spy/request-spy.middleware.d.ts} +1 -1
- package/dist/base/middlewares/request-spy/request-spy.middleware.d.ts.map +1 -0
- package/dist/base/middlewares/{request-spy.middleware.js → request-spy/request-spy.middleware.js} +1 -1
- package/dist/base/middlewares/request-spy/request-spy.middleware.js.map +1 -0
- package/dist/base/models/common/columns.d.ts +22 -0
- package/dist/base/models/common/columns.d.ts.map +1 -0
- package/dist/base/models/common/columns.js +43 -0
- package/dist/base/models/common/columns.js.map +1 -0
- package/dist/base/models/common/index.d.ts +1 -0
- package/dist/base/models/common/index.d.ts.map +1 -1
- package/dist/base/models/common/index.js +1 -0
- package/dist/base/models/common/index.js.map +1 -1
- package/dist/base/models/enrichers/principal.enricher.d.ts +6 -5
- package/dist/base/models/enrichers/principal.enricher.d.ts.map +1 -1
- package/dist/base/models/enrichers/principal.enricher.js +8 -3
- package/dist/base/models/enrichers/principal.enricher.js.map +1 -1
- package/dist/base/models/enrichers/tz.enricher.d.ts +9 -8
- package/dist/base/models/enrichers/tz.enricher.d.ts.map +1 -1
- package/dist/base/models/enrichers/tz.enricher.js +10 -10
- package/dist/base/models/enrichers/tz.enricher.js.map +1 -1
- package/dist/base/repositories/common/types.d.ts +6 -2
- package/dist/base/repositories/common/types.d.ts.map +1 -1
- package/dist/base/repositories/common/types.js +6 -4
- package/dist/base/repositories/common/types.js.map +1 -1
- package/dist/base/repositories/core/abstract.d.ts +2 -0
- package/dist/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/base/repositories/core/persistable.d.ts +6 -1
- package/dist/base/repositories/core/persistable.d.ts.map +1 -1
- package/dist/base/repositories/core/persistable.js +18 -6
- package/dist/base/repositories/core/persistable.js.map +1 -1
- package/dist/base/repositories/core/readable.d.ts.map +1 -1
- package/dist/base/repositories/core/readable.js +21 -5
- package/dist/base/repositories/core/readable.js.map +1 -1
- package/dist/base/repositories/core/soft-deletable.d.ts +1 -1
- package/dist/base/repositories/core/soft-deletable.d.ts.map +1 -1
- package/dist/base/repositories/mixins/default-filter.d.ts +3 -0
- package/dist/base/repositories/mixins/default-filter.d.ts.map +1 -1
- package/dist/base/repositories/mixins/default-filter.js +11 -0
- package/dist/base/repositories/mixins/default-filter.js.map +1 -1
- package/dist/base/repositories/operators/filter.d.ts +4 -0
- package/dist/base/repositories/operators/filter.d.ts.map +1 -1
- package/dist/base/repositories/operators/filter.js +23 -2
- package/dist/base/repositories/operators/filter.js.map +1 -1
- package/dist/components/auth/authorize/adapters/base-filtered.d.ts +26 -56
- package/dist/components/auth/authorize/adapters/base-filtered.d.ts.map +1 -1
- package/dist/components/auth/authorize/adapters/base-filtered.js +23 -70
- package/dist/components/auth/authorize/adapters/base-filtered.js.map +1 -1
- package/dist/components/auth/authorize/adapters/index.d.ts +2 -1
- package/dist/components/auth/authorize/adapters/index.d.ts.map +1 -1
- package/dist/components/auth/authorize/adapters/index.js +2 -1
- package/dist/components/auth/authorize/adapters/index.js.map +1 -1
- package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts +138 -0
- package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.d.ts.map +1 -0
- package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js +300 -0
- package/dist/components/auth/authorize/adapters/scoped-casbin.adapter.js.map +1 -0
- package/dist/components/auth/authorize/adapters/types.d.ts +31 -0
- package/dist/components/auth/authorize/adapters/types.d.ts.map +1 -0
- package/dist/components/auth/authorize/adapters/types.js +3 -0
- package/dist/components/auth/authorize/adapters/types.js.map +1 -0
- package/dist/components/auth/authorize/common/constants.d.ts +144 -8
- package/dist/components/auth/authorize/common/constants.d.ts.map +1 -1
- package/dist/components/auth/authorize/common/constants.js +171 -13
- package/dist/components/auth/authorize/common/constants.js.map +1 -1
- package/dist/components/auth/authorize/common/index.d.ts +4 -0
- package/dist/components/auth/authorize/common/index.d.ts.map +1 -1
- package/dist/components/auth/authorize/common/index.js +4 -0
- package/dist/components/auth/authorize/common/index.js.map +1 -1
- package/dist/components/auth/authorize/common/object-match.d.ts +21 -0
- package/dist/components/auth/authorize/common/object-match.d.ts.map +1 -0
- package/dist/components/auth/authorize/common/object-match.js +33 -0
- package/dist/components/auth/authorize/common/object-match.js.map +1 -0
- package/dist/components/auth/authorize/common/permission-builder.d.ts +92 -0
- package/dist/components/auth/authorize/common/permission-builder.d.ts.map +1 -0
- package/dist/components/auth/authorize/common/permission-builder.js +99 -0
- package/dist/components/auth/authorize/common/permission-builder.js.map +1 -0
- package/dist/components/auth/authorize/common/policy-builder.d.ts +183 -0
- package/dist/components/auth/authorize/common/policy-builder.d.ts.map +1 -0
- package/dist/components/auth/authorize/common/policy-builder.js +130 -0
- package/dist/components/auth/authorize/common/policy-builder.js.map +1 -0
- package/dist/components/auth/authorize/common/resolve-request-domain.d.ts +20 -0
- package/dist/components/auth/authorize/common/resolve-request-domain.d.ts.map +1 -0
- package/dist/components/auth/authorize/common/resolve-request-domain.js +59 -0
- package/dist/components/auth/authorize/common/resolve-request-domain.js.map +1 -0
- package/dist/components/auth/authorize/common/types.d.ts +70 -23
- package/dist/components/auth/authorize/common/types.d.ts.map +1 -1
- package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts +120 -28
- package/dist/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
- package/dist/components/auth/authorize/enforcers/casbin.enforcer.js +324 -124
- package/dist/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
- package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts +19 -1
- package/dist/components/auth/authorize/enforcers/enforcer-registry.d.ts.map +1 -1
- package/dist/components/auth/authorize/enforcers/enforcer-registry.js +23 -0
- package/dist/components/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
- package/dist/components/auth/authorize/enforcers/index.d.ts +1 -0
- package/dist/components/auth/authorize/enforcers/index.d.ts.map +1 -1
- package/dist/components/auth/authorize/enforcers/index.js +1 -0
- package/dist/components/auth/authorize/enforcers/index.js.map +1 -1
- package/dist/components/auth/authorize/enforcers/models/index.d.ts +2 -0
- package/dist/components/auth/authorize/enforcers/models/index.d.ts.map +1 -0
- package/dist/components/auth/authorize/enforcers/models/index.js +18 -0
- package/dist/components/auth/authorize/enforcers/models/index.js.map +1 -0
- package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts +32 -0
- package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +1 -0
- package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js +54 -0
- package/dist/components/auth/authorize/enforcers/models/rbac-domain.model.js.map +1 -0
- package/dist/components/auth/authorize/models/index.d.ts +0 -1
- package/dist/components/auth/authorize/models/index.d.ts.map +1 -1
- package/dist/components/auth/authorize/models/index.js +0 -1
- package/dist/components/auth/authorize/models/index.js.map +1 -1
- package/dist/components/auth/authorize/providers/authorization.provider.d.ts.map +1 -1
- package/dist/components/auth/authorize/providers/authorization.provider.js +12 -0
- package/dist/components/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/components/auth/models/entities/permission.model.d.ts +2 -0
- package/dist/components/auth/models/entities/permission.model.d.ts.map +1 -1
- package/dist/components/auth/models/entities/permission.model.js +4 -0
- package/dist/components/auth/models/entities/permission.model.js.map +1 -1
- package/dist/components/auth/models/entities/user.model.d.ts +16 -2
- package/dist/components/auth/models/entities/user.model.d.ts.map +1 -1
- package/dist/components/auth/models/entities/user.model.js +3 -2
- package/dist/components/auth/models/entities/user.model.js.map +1 -1
- package/dist/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +1 -1
- package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -1
- package/dist/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
- package/dist/components/static-asset/models/base.model.d.ts +24 -16
- package/dist/components/static-asset/models/base.model.d.ts.map +1 -1
- package/dist/helpers/inversion/common/types.d.ts +2 -0
- package/dist/helpers/inversion/common/types.d.ts.map +1 -1
- package/package.json +28 -27
- package/dist/base/middlewares/app-error.middleware.d.ts +0 -8
- package/dist/base/middlewares/app-error.middleware.d.ts.map +0 -1
- package/dist/base/middlewares/app-error.middleware.js +0 -138
- package/dist/base/middlewares/app-error.middleware.js.map +0 -1
- package/dist/base/middlewares/emoji-favicon.middleware.d.ts.map +0 -1
- package/dist/base/middlewares/emoji-favicon.middleware.js.map +0 -1
- package/dist/base/middlewares/not-found.middleware.d.ts.map +0 -1
- package/dist/base/middlewares/request-spy.middleware.d.ts.map +0 -1
- package/dist/base/middlewares/request-spy.middleware.js.map +0 -1
- package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts +0 -40
- package/dist/components/auth/authorize/adapters/drizzle-casbin.d.ts.map +0 -1
- package/dist/components/auth/authorize/adapters/drizzle-casbin.js +0 -99
- package/dist/components/auth/authorize/adapters/drizzle-casbin.js.map +0 -1
- package/dist/components/auth/authorize/models/abilities/index.d.ts +0 -3
- package/dist/components/auth/authorize/models/abilities/index.d.ts.map +0 -1
- package/dist/components/auth/authorize/models/abilities/index.js.map +0 -1
- package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts +0 -14
- package/dist/components/auth/authorize/models/abilities/string-action.model.d.ts.map +0 -1
- package/dist/components/auth/authorize/models/abilities/string-action.model.js +0 -23
- package/dist/components/auth/authorize/models/abilities/string-action.model.js.map +0 -1
- package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts +0 -13
- package/dist/components/auth/authorize/models/abilities/string-resource.model.d.ts.map +0 -1
- package/dist/components/auth/authorize/models/abilities/string-resource.model.js +0 -19
- package/dist/components/auth/authorize/models/abilities/string-resource.model.js.map +0 -1
- /package/dist/base/middlewares/{emoji-favicon.middleware.d.ts → emoji-favicon/emoji-favicon.middleware.d.ts} +0 -0
- /package/dist/base/middlewares/{emoji-favicon.middleware.js → emoji-favicon/emoji-favicon.middleware.js} +0 -0
|
@@ -1,35 +1,97 @@
|
|
|
1
1
|
import { TContext } from '../../../../base/controllers/common/types';
|
|
2
|
-
import { BaseHelper } from '@venizia/ignis-helpers';
|
|
3
|
-
import type {
|
|
2
|
+
import { BaseHelper, TNullable } from '@venizia/ignis-helpers';
|
|
3
|
+
import type { Enforcer as CasbinEnforcerType } from 'casbin';
|
|
4
4
|
import { Env } from 'hono';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { IAuthorizationEnforcer, IAuthorizationUser, ICasbinEnforcerCachedRedis, ICasbinEnforcerOptions, ICasbinRules, type IAuthorizationRequest, type TAuthorizationDecision, type TCasbinDomainMatchingFunction } from '../common';
|
|
6
|
+
/** Normalizer for the scoped/custom payload path — the exact shape returned by defaultScopedPayloadFn(). */
|
|
7
|
+
type TNormalizePayloadFn<E extends Env, TAction, TResource> = (opts: {
|
|
8
|
+
user: IAuthorizationUser;
|
|
9
|
+
action: TAction;
|
|
10
|
+
resource: TResource;
|
|
11
|
+
context: TContext<E, string>;
|
|
12
|
+
}) => {
|
|
13
|
+
subject: string;
|
|
14
|
+
resource: string;
|
|
15
|
+
action: string;
|
|
16
|
+
domain?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class CasbinAuthorizationEnforcer<E extends Env = Env, TAction extends string = string, TResource extends string = string> extends BaseHelper implements IAuthorizationEnforcer<E, TAction, TResource, ICasbinRules> {
|
|
8
19
|
private options;
|
|
9
20
|
name: string;
|
|
10
21
|
private readonly MIN_EXPIRES_IN;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
22
|
+
private pool;
|
|
23
|
+
private helper;
|
|
24
|
+
private readonly pendingLineFetches;
|
|
25
|
+
private resolvedPayloadFn;
|
|
13
26
|
constructor(options: ICasbinEnforcerOptions<E, TAction, TResource>);
|
|
14
27
|
configure(): Promise<void>;
|
|
15
28
|
destroy(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Boot-time smoke test for the matcher. casbin compiles the matcher expression LAZILY — not in
|
|
31
|
+
* newEnforcer() or buildRoleLinks(), but on the first enforce — so a broken matcher would otherwise
|
|
32
|
+
* only surface on the first real request (a 500 for a real user). Running one dummy enforceSync here
|
|
33
|
+
* forces that compile at warmup, turning these into a fail-at-boot for an authz component:
|
|
34
|
+
* - matcher syntax errors in the model,
|
|
35
|
+
* - references to functions that registerMatchers() didn't register (e.g. a renamed g-relation),
|
|
36
|
+
* - request arity mismatch (4-token scoped model vs the 3/4 args we pass).
|
|
37
|
+
* Bonus: enforceSync also throws if a matcher func is async — but every func we register is a sync
|
|
38
|
+
* built-in, so that branch is effectively unreachable; the real value is the compile/wiring check above.
|
|
39
|
+
*/
|
|
40
|
+
protected assertMatcherCompilesSync(opts: {
|
|
41
|
+
enforcer: CasbinEnforcerType;
|
|
42
|
+
}): void;
|
|
16
43
|
buildRules(opts: {
|
|
17
|
-
user:
|
|
18
|
-
principalType: string;
|
|
19
|
-
} & IAuthUser;
|
|
44
|
+
user: IAuthorizationUser;
|
|
20
45
|
context: TContext<E, string>;
|
|
21
|
-
}): Promise<
|
|
46
|
+
}): Promise<ICasbinRules>;
|
|
22
47
|
evaluate(opts: {
|
|
23
|
-
rules:
|
|
48
|
+
rules: ICasbinRules;
|
|
24
49
|
request: IAuthorizationRequest<TAction, TResource>;
|
|
25
50
|
context: TContext<E, string>;
|
|
26
51
|
}): Promise<TAuthorizationDecision>;
|
|
27
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Run the matcher synchronously and, on DENY, log WHICH policy rule decided it. enforceExSync returns
|
|
54
|
+
* `[isAllowed, matchedPolicy]` where matchedPolicy is the deciding rule (or `[]` when nothing matched →
|
|
55
|
+
* default-deny). The explain index is computed by the effector regardless of this call, so capturing it
|
|
56
|
+
* carries no meaningful cost over enforceSync — it just surfaces the reason for a denial to the logs.
|
|
57
|
+
*/
|
|
58
|
+
protected enforceWithExplain(opts: {
|
|
59
|
+
enforcer: CasbinEnforcerType;
|
|
60
|
+
vals: string[];
|
|
61
|
+
}): boolean;
|
|
62
|
+
invalidateUserCache(opts: {
|
|
63
|
+
user: IAuthorizationUser;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
invalidatedKeys: number;
|
|
66
|
+
}>;
|
|
67
|
+
rebuildUserCache(opts: {
|
|
68
|
+
user: IAuthorizationUser;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
cacheKey: string;
|
|
71
|
+
lineCount: number;
|
|
72
|
+
}>;
|
|
73
|
+
/** Compute the user's cache key and reject an empty result — consistent with the read path. */
|
|
74
|
+
protected resolveCacheKey(opts: {
|
|
75
|
+
user: IAuthorizationUser;
|
|
76
|
+
cached: ICasbinEnforcerCachedRedis & {
|
|
77
|
+
use: true;
|
|
78
|
+
};
|
|
79
|
+
}): Promise<string>;
|
|
80
|
+
/** Narrow `options.cached` to the redis variant; cache management is redis-only. */
|
|
81
|
+
protected requireRedisCache(): ICasbinEnforcerCachedRedis & {
|
|
82
|
+
use: true;
|
|
83
|
+
};
|
|
84
|
+
protected registerMatchers(opts: {
|
|
85
|
+
enforcer: CasbinEnforcerType;
|
|
86
|
+
casbin: typeof import('casbin');
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
/** Map a CasbinDomainMatchingFunctions value to casbin's Util.*Func matcher. */
|
|
89
|
+
protected resolveDomainMatchingFn(opts: {
|
|
28
90
|
casbin: typeof import('casbin');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
91
|
+
name: TCasbinDomainMatchingFunction;
|
|
92
|
+
}): (arg1: string, arg2: string) => boolean;
|
|
93
|
+
/** Default (sub,dom,obj,act) payload for the scoped model; domain comes from request.domain. */
|
|
94
|
+
protected defaultScopedPayloadFn(): TNormalizePayloadFn<E, TAction, TResource> | undefined;
|
|
33
95
|
protected resolveModel(opts: {
|
|
34
96
|
casbin: typeof import('casbin');
|
|
35
97
|
model: ICasbinEnforcerOptions['model'];
|
|
@@ -37,20 +99,50 @@ export declare class CasbinAuthorizationEnforcer<E extends Env = Env, TAction ex
|
|
|
37
99
|
protected validateExpiresIn(opts: {
|
|
38
100
|
expiresIn: number;
|
|
39
101
|
}): void;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cached: ICasbinEnforcerCachedRedis
|
|
102
|
+
/**
|
|
103
|
+
* Fetch the user's policy lines, collapsing concurrent cache misses for the same key onto a single
|
|
104
|
+
* extraction (via `pendingLineFetches`) instead of letting every request hit the DB at once.
|
|
105
|
+
* Note: best-effort — two misses can both get past the cache read before either records its fetch
|
|
106
|
+
* in the map, so both extract once (benign: per-user lines are identical). It collapses the common
|
|
107
|
+
* case; the fast cache-hit path stays OUTSIDE the map to avoid needless contention.
|
|
108
|
+
*/
|
|
109
|
+
protected fetchLinesWithRedisCache(opts: {
|
|
110
|
+
user: IAuthorizationUser;
|
|
111
|
+
cached: ICasbinEnforcerCachedRedis & {
|
|
112
|
+
use: true;
|
|
113
|
+
};
|
|
114
|
+
}): Promise<string[]>;
|
|
115
|
+
/** Single source of truth for the Redis cache encoding. Used by miss-path and rebuild. */
|
|
116
|
+
protected writeCachedPolicyLines(opts: {
|
|
117
|
+
cacheKey: string;
|
|
118
|
+
lines: string[];
|
|
119
|
+
options: ICasbinEnforcerCachedRedis['options'];
|
|
50
120
|
}): Promise<void>;
|
|
51
|
-
|
|
121
|
+
/** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */
|
|
122
|
+
protected parseCachedPolicyLines(opts: {
|
|
123
|
+
raw: string;
|
|
124
|
+
cacheKey: string;
|
|
125
|
+
}): TNullable<string[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Extract a user's policy lines from an ISOLATED throwaway enforcer (its own model + the adapter),
|
|
128
|
+
* never a pooled serving enforcer. This is the core of the anti-poisoning design: concurrent requests
|
|
129
|
+
* on pooled enforcers can't change what we cache for this user. Used by buildRules + rebuild.
|
|
130
|
+
*/
|
|
131
|
+
protected extractUserLines(opts: {
|
|
132
|
+
user: IAuthorizationUser;
|
|
133
|
+
}): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Serialize ALL policy + grouping rule types of an enforcer's model back into casbin lines.
|
|
136
|
+
* Covers every p-type (p, p2, …) and g-type (g, g2, g3, g4, g5, …) — not just `p`/`g` — so the
|
|
137
|
+
* cached payload is complete for the scoped model (resource/action/domain hierarchies + membership).
|
|
138
|
+
* Reads stored rules (independent of role-link matching funcs), so the loader needs none registered.
|
|
139
|
+
*/
|
|
140
|
+
protected extractLinesFrom(enforcer: CasbinEnforcerType): Promise<string[]>;
|
|
141
|
+
/** Atomically reset a borrowed enforcer's model to exactly `lines` + rebuild role links. */
|
|
52
142
|
protected loadPolicyLinesIntoModel(opts: {
|
|
143
|
+
enforcer: CasbinEnforcerType;
|
|
53
144
|
lines: string[];
|
|
54
145
|
}): Promise<void>;
|
|
55
146
|
}
|
|
147
|
+
export {};
|
|
56
148
|
//# sourceMappingURL=casbin.enforcer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casbin.enforcer.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"casbin.enforcer.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/authorize/enforcers/casbin.enforcer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAkC,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,KAAK,EAAE,QAAQ,IAAI,kBAAkB,EAA8B,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EASL,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,YAAY,EAEZ,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAEnB,4GAA4G;AAC5G,KAAK,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC,IAAI,EAAE;IACnE,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAC9B,KAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAU7E,qBAAa,2BAA2B,CACtC,CAAC,S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