@forge-fr/authorization 1.0.0 → 1.1.0
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 +19 -0
- package/README.md +1 -1
- package/dist/authorizer.d.ts +3 -3
- package/dist/authorizer.d.ts.map +1 -1
- package/dist/ownership.d.ts +7 -5
- package/dist/ownership.d.ts.map +1 -1
- package/dist/ownership.js +6 -2
- package/dist/ownership.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/tenant.d.ts +7 -5
- package/dist/tenant.d.ts.map +1 -1
- package/dist/tenant.js +5 -2
- package/dist/tenant.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -4
- package/dist/types.js.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Production Ecosystem Expansion (`v1.1.0`) across all 25 `@forge-fr/*` packages:
|
|
8
|
+
|
|
9
|
+
- **End-to-End Type-Safe RPC Client (`@forge-fr/client`):** Zero-codegen route contracts (`defineContract`, `defineRoute`), server registration (`mountContract`), and typed Fetch client (`createForgeClient`) with retries, timeouts, and interceptors.
|
|
10
|
+
- **Multi-Engine Database & Edge-Native Storage/Cache (`@forge-fr/database`, `@forge-fr/cache`, `@forge-fr/storage`):** Added LibSQL/Turso, Cloudflare D1, MySQL/PlanetScale, and Neon HTTP SQL drivers, Cloudflare KV & Upstash Redis REST cache adapters, and Cloudflare R2 storage adapter.
|
|
11
|
+
- **Horizontal Realtime Scaling (`@forge-fr/http/realtime`):** Added `RealtimeRoomHub`, distributed presence with TTL heartbeats, Redis Pub/Sub & BroadcastChannel backplanes, and backpressure guards.
|
|
12
|
+
- **Production Ecosystem Plugins (`@forge-fr/webhooks`, `@forge-fr/mail`, `@forge-fr/ai`):** Added zero-dependency Web Crypto HMAC-SHA256 webhook verification & signed delivery, Fetch-native transactional mailer (Resend, Postmark, SendGrid, Console, Memory), and Edge-native AI SSE streaming, tool-calling, and structured JSON generation (OpenAI, Anthropic, Gemini, Mock).
|
|
13
|
+
- **Node/Express Bridge, Core Hardening & OSS Automation:** Added `toNodeHandler` / `createNodeMiddleware`, Node multipart streaming (`parseNodeMultipart` / `readNodeMultipartStream`), `kernel.prepare()`, `interface`-compatible `EventMap`, numeric IDs in `@forge-fr/authorization`, deploy-ready starter templates (`examples/`), and automated PR security/boundary review (`npm run pr:review`).
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @forge-fr/core@1.1.0
|
|
19
|
+
- @forge-fr/http@1.1.0
|
|
20
|
+
- @forge-fr/auth@1.1.0
|
|
21
|
+
|
|
3
22
|
## 0.1.0 - 2026-11-25
|
|
4
23
|
|
|
5
24
|
- Initial release of `@forge-fr/authorization` (Phase 4 — Milestone 4.4).
|
package/README.md
CHANGED
|
@@ -8,5 +8,5 @@ Enforceable identically inside Layer 1/2 application services and HTTP route bou
|
|
|
8
8
|
|
|
9
9
|
- **RBAC & Granular Permissions:** `createRbacRegistry()`, segment-strict wildcard matching (`invoice:*`, `*:read`, `*`), explicit deny rules (`!invoice:delete`) that always override allow, and startup role-inheritance cycle detection.
|
|
10
10
|
- **Policy Engine:** `definePolicy()`, `createPolicyEngine()`, deny-overrides-allow evaluation, fail-closed predicate exception handling, and structured `onDecision` audit hooks.
|
|
11
|
-
- **Ownership & Multi-Tenant Guards:** `checkOwnership()`, `assertOwnership()`, `checkTenantIsolation()`, `assertTenantIsolation()`, `assertTenantParamMatch()` blocking cross-user IDOR and cross-tenant data access.
|
|
11
|
+
- **Ownership & Multi-Tenant Guards:** `checkOwnership()`, `assertOwnership()`, `checkTenantIsolation()`, `assertTenantIsolation()`, `assertTenantParamMatch()` blocking cross-user IDOR and cross-tenant data access, supporting both `string | number` actor/owner/tenant IDs and custom error `message` overrides.
|
|
12
12
|
- **Unified Service & HTTP Authorizer:** `createAuthorizer()`, `authorizer.forActor(actor)` for service boundaries, plus `requireRoles()`, `requirePermissions()`, `requireTenantParam()`, `createAuthorizationMiddleware()`, and `createAuthorizationPlugin()`.
|
package/dist/authorizer.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface ActorAuthorizer {
|
|
|
21
21
|
hasPermission(permission: string): boolean;
|
|
22
22
|
assertPermission(permission: string): void;
|
|
23
23
|
assertOwner<TResource = OwnedResource>(resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): void;
|
|
24
|
-
assertTenant<TResource = TenantScopedResource>(resourceOrTenantId: TResource | string | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
24
|
+
assertTenant<TResource = TenantScopedResource>(resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
25
25
|
}
|
|
26
26
|
export interface Authorizer {
|
|
27
27
|
readonly rbac: RbacRegistry;
|
|
@@ -35,8 +35,8 @@ export interface Authorizer {
|
|
|
35
35
|
assertPermission(actor: Actor | null | undefined, permission: string): void;
|
|
36
36
|
checkOwner<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): AuthorizationDecision;
|
|
37
37
|
assertOwner<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): void;
|
|
38
|
-
checkTenant<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | null | undefined, options?: TenantGuardOptions<TResource>): AuthorizationDecision;
|
|
39
|
-
assertTenant<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
38
|
+
checkTenant<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): AuthorizationDecision;
|
|
39
|
+
assertTenant<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
40
40
|
forActor(actor: Actor | null | undefined): ActorAuthorizer;
|
|
41
41
|
}
|
|
42
42
|
export declare function createAuthorizer(options?: AuthorizerOptions): Authorizer;
|
package/dist/authorizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizer.d.ts","sourceRoot":"","sources":["../src/authorizer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACpD,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAC1C,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrD,QAAQ,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK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,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAClE,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACtC,qBAAqB,CAAC;IACzB,YAAY,CAAC,SAAS,GAAG,oBAAoB,EAC3C,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAClE,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACtC,IAAI,CAAC;IACR,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CAAC;CAC5D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CA0G5E"}
|
package/dist/ownership.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type Actor, type AuthorizationDecision } from './types.js';
|
|
2
2
|
import { type TenantScopedResource } from './tenant.js';
|
|
3
3
|
export interface OwnedResource extends TenantScopedResource {
|
|
4
|
-
readonly ownerId?: string | null;
|
|
5
|
-
readonly userId?: string | null;
|
|
6
|
-
readonly createdBy?: string | null;
|
|
4
|
+
readonly ownerId?: string | number | null;
|
|
5
|
+
readonly userId?: string | number | null;
|
|
6
|
+
readonly createdBy?: string | number | null;
|
|
7
7
|
}
|
|
8
8
|
export interface OwnershipOptions<TResource = OwnedResource> {
|
|
9
9
|
/** Custom extractor for resource owner subject ID. */
|
|
10
|
-
readonly getOwnerId?: (resource: TResource) => string | null | undefined;
|
|
10
|
+
readonly getOwnerId?: (resource: TResource) => string | number | null | undefined;
|
|
11
11
|
/** Custom extractor for resource tenant ID. */
|
|
12
|
-
readonly getResourceTenantId?: (resource: TResource) => string | null | undefined;
|
|
12
|
+
readonly getResourceTenantId?: (resource: TResource) => string | number | null | undefined;
|
|
13
13
|
/**
|
|
14
14
|
* Enforces tenant match alongside ownership whenever a resource carries tenantId
|
|
15
15
|
* (defaults to `true` to prevent cross-tenant admin IDOR).
|
|
@@ -19,6 +19,8 @@ export interface OwnershipOptions<TResource = OwnedResource> {
|
|
|
19
19
|
readonly bypassRoles?: readonly string[];
|
|
20
20
|
/** Explicit cross-tenant system bypass predicate. */
|
|
21
21
|
readonly allowSystemBypass?: (actor: Actor) => boolean;
|
|
22
|
+
/** Custom forbidden error message (defaults to 'Access denied'). */
|
|
23
|
+
readonly message?: string;
|
|
22
24
|
}
|
|
23
25
|
export declare function checkOwnership<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): AuthorizationDecision;
|
|
24
26
|
export declare function assertOwnership<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): void;
|
package/dist/ownership.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9E,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,M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-fr/core';
|
|
|
2
2
|
import { createDecision, isValidActor, } from './types.js';
|
|
3
3
|
import { checkTenantIsolation } from './tenant.js';
|
|
4
4
|
function normalizeId(value) {
|
|
5
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
6
|
+
return String(value);
|
|
7
|
+
}
|
|
5
8
|
if (typeof value !== 'string') {
|
|
6
9
|
return null;
|
|
7
10
|
}
|
|
@@ -60,7 +63,8 @@ export function checkOwnership(actor, resource, options) {
|
|
|
60
63
|
if (ownerId === null) {
|
|
61
64
|
return createDecision(false, 'Resource has no owner');
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
const actorSubject = normalizeId(actor.subject);
|
|
67
|
+
if (actorSubject === null || actorSubject !== ownerId) {
|
|
64
68
|
return createDecision(false, 'Actor does not own resource');
|
|
65
69
|
}
|
|
66
70
|
return createDecision(true, 'Resource ownership verified', 'ownership:match');
|
|
@@ -71,7 +75,7 @@ export function assertOwnership(actor, resource, options) {
|
|
|
71
75
|
}
|
|
72
76
|
const decision = checkOwnership(actor, resource, options);
|
|
73
77
|
if (!decision.allowed) {
|
|
74
|
-
throw new ForbiddenError('Access denied');
|
|
78
|
+
throw new ForbiddenError(options?.message ?? 'Access denied');
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
//# sourceMappingURL=ownership.js.map
|
package/dist/ownership.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.js","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,cAAc,EACd,YAAY,GAGb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAA6B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ownership.js","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE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AAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACjF,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,cAAc,CAAC,IAAI,EAAE,uCAAuC,EAAE,uBAAuB,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,cAAc,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC;QACtD,OAAO,cAAc,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,cAAc,CAAC,IAAI,EAAE,6BAA6B,EAAE,iBAAiB,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,KAA+B,EAC/B,QAAsC,EACtC,OAAqC;IAErC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,IAAI,eAAe,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,7 +7,7 @@ export const AuthorizationTokens = Object.freeze({
|
|
|
7
7
|
export function createAuthorizationPlugin(options = {}) {
|
|
8
8
|
return definePlugin({
|
|
9
9
|
name: options.name ?? '@forge-fr/authorization',
|
|
10
|
-
version: options.version ?? '1.
|
|
10
|
+
version: options.version ?? '1.1.0',
|
|
11
11
|
forgeVersion: options.forgeVersion ?? '^0.1.0 || ^1.0.0-rc.1 || ^1.0.0',
|
|
12
12
|
capabilities: ['di:register'],
|
|
13
13
|
register(ctx, rawConfig) {
|
package/dist/tenant.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { type Actor, type AuthorizationDecision } from './types.js';
|
|
2
2
|
export interface TenantScopedResource {
|
|
3
|
-
readonly tenantId?: string | null;
|
|
3
|
+
readonly tenantId?: string | number | null;
|
|
4
4
|
}
|
|
5
5
|
export interface TenantGuardOptions<TResource = TenantScopedResource> {
|
|
6
6
|
/** Optional explicit bypass predicate for verified cross-tenant system actors. */
|
|
7
7
|
readonly allowSystemBypass?: (actor: Actor) => boolean;
|
|
8
8
|
/** Custom extractor for resource tenantId (defaults to `resource.tenantId`). */
|
|
9
|
-
readonly getResourceTenantId?: (resource: TResource) => string | null | undefined;
|
|
9
|
+
readonly getResourceTenantId?: (resource: TResource) => string | number | null | undefined;
|
|
10
|
+
/** Custom forbidden error message (defaults to 'Access denied'). */
|
|
11
|
+
readonly message?: string;
|
|
10
12
|
}
|
|
11
|
-
export declare function checkTenantIsolation<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | null | undefined, options?: TenantGuardOptions<TResource>): AuthorizationDecision;
|
|
12
|
-
export declare function assertTenantIsolation<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
13
|
-
export declare function assertTenantParamMatch(actor: Actor | null | undefined, requestedTenantId: string | null | undefined, options?: Omit<TenantGuardOptions<string>, 'getResourceTenantId'>): void;
|
|
13
|
+
export declare function checkTenantIsolation<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): AuthorizationDecision;
|
|
14
|
+
export declare function assertTenantIsolation<TResource = TenantScopedResource>(actor: Actor | null | undefined, resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): void;
|
|
15
|
+
export declare function assertTenantParamMatch(actor: Actor | null | undefined, requestedTenantId: string | number | null | undefined, options?: Omit<TenantGuardOptions<string | number>, 'getResourceTenantId'>): void;
|
|
14
16
|
//# sourceMappingURL=tenant.d.ts.map
|
package/dist/tenant.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB,CAAC,SAAS,GAAG,oBAAoB;IAClE,kFAAkF;IAClF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACvD,gFAAgF;IAChF,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3F,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAgCD,wBAAgB,oBAAoB,CAAC,SAAS,GAAG,oBAAoB,EACnE,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAClE,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACtC,qBAAqB,CA8BvB;AAED,wBAAgB,qBAAqB,CAAC,SAAS,GAAG,oBAAoB,EACpE,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAClE,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,GACtC,IAAI,CASN;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACrD,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,qBAAqB,CAAC,GACzE,IAAI,CAEN"}
|
package/dist/tenant.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ForbiddenError, UnauthorizedError } from '@forge-fr/core';
|
|
2
2
|
import { createDecision, isValidActor, } from './types.js';
|
|
3
3
|
function normalizeTenantId(value) {
|
|
4
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
5
|
+
return String(value);
|
|
6
|
+
}
|
|
4
7
|
if (typeof value !== 'string') {
|
|
5
8
|
return null;
|
|
6
9
|
}
|
|
@@ -8,7 +11,7 @@ function normalizeTenantId(value) {
|
|
|
8
11
|
return trimmed.length > 0 ? trimmed : null;
|
|
9
12
|
}
|
|
10
13
|
function extractTargetTenantId(resourceOrTenantId, options) {
|
|
11
|
-
if (typeof resourceOrTenantId === 'string') {
|
|
14
|
+
if (typeof resourceOrTenantId === 'string' || typeof resourceOrTenantId === 'number') {
|
|
12
15
|
return normalizeTenantId(resourceOrTenantId);
|
|
13
16
|
}
|
|
14
17
|
if (resourceOrTenantId === null || resourceOrTenantId === undefined) {
|
|
@@ -55,7 +58,7 @@ export function assertTenantIsolation(actor, resourceOrTenantId, options) {
|
|
|
55
58
|
}
|
|
56
59
|
const decision = checkTenantIsolation(actor, resourceOrTenantId, options);
|
|
57
60
|
if (!decision.allowed) {
|
|
58
|
-
throw new ForbiddenError('Access denied');
|
|
61
|
+
throw new ForbiddenError(options?.message ?? 'Access denied');
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
export function assertTenantParamMatch(actor, requestedTenantId, options) {
|
package/dist/tenant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,cAAc,EACd,YAAY,GAGb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,cAAc,EACd,YAAY,GAGb,MAAM,YAAY,CAAC;AAepB,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAA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AAC;IACxD,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC,KAAK,EAAE,iCAAiC,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,cAAc,GAAG,qBAAqB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC1E,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,cAAc,CAAC,KAAK,EAAE,2CAA2C,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,aAAa,KAAK,cAAc,EAAE,CAAC;QACrC,OAAO,cAAc,CAAC,KAAK,EAAE,4BAA4B,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,cAAc,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAA+B,EAC/B,kBAAkE,EAClE,OAAuC;IAEvC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC1E,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,OAAO,IAAI,eAAe,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAA+B,EAC/B,iBAAqD,EACrD,OAA0E;IAE1E,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuthIdentity } from '@forge-fr/auth';
|
|
2
2
|
export interface Actor {
|
|
3
|
-
readonly subject: string;
|
|
4
|
-
readonly tenantId?: string;
|
|
3
|
+
readonly subject: string | number;
|
|
4
|
+
readonly tenantId?: string | number;
|
|
5
5
|
readonly roles: readonly string[];
|
|
6
6
|
readonly permissions: readonly string[];
|
|
7
7
|
readonly scopes: readonly string[];
|
|
@@ -16,8 +16,8 @@ export interface AuthorizationDecision {
|
|
|
16
16
|
readonly matchedRule?: string;
|
|
17
17
|
}
|
|
18
18
|
export interface AuthorizationAuditEvent {
|
|
19
|
-
readonly subject: string | null;
|
|
20
|
-
readonly tenantId: string | null;
|
|
19
|
+
readonly subject: string | number | null;
|
|
20
|
+
readonly tenantId: string | number | null;
|
|
21
21
|
readonly action: string;
|
|
22
22
|
readonly allowed: boolean;
|
|
23
23
|
readonly effect: AuthorizationEffect;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC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,CAAC,EAAE,MAAM,GACnB,qBAAqB,CAOvB"}
|
package/dist/types.js
CHANGED
|
@@ -9,10 +9,16 @@ export function isForbiddenKey(key) {
|
|
|
9
9
|
return FORBIDDEN_KEYS.has(key);
|
|
10
10
|
}
|
|
11
11
|
export function isValidActor(actor) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (actor === null || actor === undefined) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (typeof actor.subject === 'string') {
|
|
16
|
+
return actor.subject.trim().length > 0;
|
|
17
|
+
}
|
|
18
|
+
if (typeof actor.subject === 'number') {
|
|
19
|
+
return Number.isFinite(actor.subject);
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
16
22
|
}
|
|
17
23
|
export function actorFromIdentity(identity) {
|
|
18
24
|
return Object.freeze({
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACzD,WAAW;IACX,aAAa;IACb,WAAW;IACX,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAA+B;IAC1D,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACzD,WAAW;IACX,aAAa;IACb,WAAW;IACX,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,MAAM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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge-fr/authorization",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "RBAC, permissions, policy engine, ownership checks, and multi-tenant authorization guards for ForgeJS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"import": "./dist/index.js",
|
|
27
27
|
"default": "./dist/index.js"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
29
30
|
},
|
|
30
31
|
"main": "./dist/index.js",
|
|
31
32
|
"types": "./dist/index.d.ts",
|
|
@@ -36,9 +37,9 @@
|
|
|
36
37
|
"LICENSE"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@forge-fr/auth": "^1.
|
|
40
|
-
"@forge-fr/core": "^1.
|
|
41
|
-
"@forge-fr/http": "^1.
|
|
40
|
+
"@forge-fr/auth": "^1.1.0",
|
|
41
|
+
"@forge-fr/core": "^1.1.0",
|
|
42
|
+
"@forge-fr/http": "^1.1.0"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"build": "tsc -b tsconfig.json",
|