@forge-fr/authorization 0.0.0-stage → 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 ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
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
+
22
+ ## 0.1.0 - 2026-11-25
23
+
24
+ - Initial release of `@forge-fr/authorization` (Phase 4 — Milestone 4.4).
25
+ - Added RBAC registry with cycle detection, segment-strict permissions, and deny-overrides-allow precedence.
26
+ - Added async policy engine with fail-closed evaluation and decision audit hooks.
27
+ - Added resource ownership (anti-IDOR) and multi-tenant isolation guards usable at both service and HTTP route boundaries.
28
+ - Added HTTP route middleware guards (`requireRoles`, `requirePermissions`, `requireTenantParam`, `createAuthorizationMiddleware`) and `createAuthorizationPlugin()`.
29
+
30
+ ## [1.0.0] - 2026-11-27
31
+
32
+ ### Added & Changed
33
+ - Synchronized `@forge-fr/authorization` to `1.0.0` General Availability with typed `AuthIdentityKey` integration.
34
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ForgeJS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # Temporary Holding Version
1
+ # @forge-fr/authorization
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Fail-closed authorization primitives for ForgeJS: RBAC with inheritance cycle detection, segment-strict permissions with deny-overrides-allow precedence, async policy engine, resource ownership (anti-IDOR) checks, multi-tenant isolation guards, HTTP route middleware, and ForgeJS DI plugin.
4
+
5
+ Enforceable identically inside Layer 1/2 application services and HTTP route boundaries across Node.js and Bun.
6
+
7
+ ## Key Capabilities
8
+
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
+ - **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, supporting both `string | number` actor/owner/tenant IDs and custom error `message` overrides.
12
+ - **Unified Service & HTTP Authorizer:** `createAuthorizer()`, `authorizer.forActor(actor)` for service boundaries, plus `requireRoles()`, `requirePermissions()`, `requireTenantParam()`, `createAuthorizationMiddleware()`, and `createAuthorizationPlugin()`.
@@ -0,0 +1,43 @@
1
+ import { type RbacRegistry, type RoleDefinitionsMap } from './permissions.js';
2
+ import { type OwnedResource, type OwnershipOptions } from './ownership.js';
3
+ import { type PolicyEngine, type PolicyRule } from './policy.js';
4
+ import { type TenantGuardOptions, type TenantScopedResource } from './tenant.js';
5
+ import { type Actor, type AuthorizationAuditHook, type AuthorizationDecision } from './types.js';
6
+ export interface AuthorizerOptions {
7
+ readonly roles?: RoleDefinitionsMap;
8
+ readonly rbac?: RbacRegistry;
9
+ readonly policies?: readonly PolicyRule<any, any>[];
10
+ readonly enforceTenantIsolation?: boolean;
11
+ readonly tenantOptions?: TenantGuardOptions<unknown>;
12
+ readonly onDecision?: AuthorizationAuditHook;
13
+ }
14
+ export interface ActorAuthorizer {
15
+ readonly actor: Actor | null | undefined;
16
+ evaluate<TResource = unknown, TContext = unknown>(action: string, resource?: TResource, context?: TContext): Promise<AuthorizationDecision>;
17
+ can<TResource = unknown, TContext = unknown>(action: string, resource?: TResource, context?: TContext): Promise<boolean>;
18
+ assert<TResource = unknown, TContext = unknown>(action: string, resource?: TResource, context?: TContext): Promise<void>;
19
+ hasRole(role: string): boolean;
20
+ assertRole(role: string): void;
21
+ hasPermission(permission: string): boolean;
22
+ assertPermission(permission: string): void;
23
+ assertOwner<TResource = OwnedResource>(resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): void;
24
+ assertTenant<TResource = TenantScopedResource>(resourceOrTenantId: TResource | string | number | null | undefined, options?: TenantGuardOptions<TResource>): void;
25
+ }
26
+ export interface Authorizer {
27
+ readonly rbac: RbacRegistry;
28
+ readonly policyEngine: PolicyEngine;
29
+ evaluate<TResource = unknown, TContext = unknown>(actor: Actor | null | undefined, action: string, resource?: TResource, context?: TContext): Promise<AuthorizationDecision>;
30
+ can<TResource = unknown, TContext = unknown>(actor: Actor | null | undefined, action: string, resource?: TResource, context?: TContext): Promise<boolean>;
31
+ assert<TResource = unknown, TContext = unknown>(actor: Actor | null | undefined, action: string, resource?: TResource, context?: TContext): Promise<void>;
32
+ hasRole(actor: Actor | null | undefined, role: string): boolean;
33
+ assertRole(actor: Actor | null | undefined, role: string): void;
34
+ hasPermission(actor: Actor | null | undefined, permission: string): boolean;
35
+ assertPermission(actor: Actor | null | undefined, permission: string): void;
36
+ checkOwner<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): AuthorizationDecision;
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 | 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
+ forActor(actor: Actor | null | undefined): ActorAuthorizer;
41
+ }
42
+ export declare function createAuthorizer(options?: AuthorizerOptions): Authorizer;
43
+ //# sourceMappingURL=authorizer.d.ts.map
@@ -0,0 +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,C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,IAAI,GAAG,SAAS,EAC/B,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,GACpC,qBAAqB,CAAC;IACzB,WAAW,CAAC,SAAS,GAAG,aAAa,EACnC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,GACpC,IAAI,CAAC;IACR,WAAW,CAAC,SAAS,GAAG,oBAAoB,EAC1C,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,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"}
@@ -0,0 +1,89 @@
1
+ import { ForbiddenError, UnauthorizedError } from '@forge-fr/core';
2
+ import { createRbacRegistry, } from './permissions.js';
3
+ import { assertOwnership, checkOwnership, } from './ownership.js';
4
+ import { createPolicyEngine, } from './policy.js';
5
+ import { assertTenantIsolation, checkTenantIsolation, } from './tenant.js';
6
+ import { isValidActor, } from './types.js';
7
+ export function createAuthorizer(options = {}) {
8
+ const rbac = options.rbac ?? createRbacRegistry(options.roles ?? {});
9
+ const policyEngine = createPolicyEngine({
10
+ rbac,
11
+ ...(options.policies !== undefined ? { policies: options.policies } : {}),
12
+ ...(options.enforceTenantIsolation !== undefined
13
+ ? { enforceTenantIsolation: options.enforceTenantIsolation }
14
+ : {}),
15
+ ...(options.tenantOptions !== undefined ? { tenantOptions: options.tenantOptions } : {}),
16
+ ...(options.onDecision !== undefined ? { onDecision: options.onDecision } : {}),
17
+ });
18
+ async function evaluate(actor, action, resource, context) {
19
+ return policyEngine.evaluate(actor, action, resource, context);
20
+ }
21
+ async function can(actor, action, resource, context) {
22
+ const decision = await evaluate(actor, action, resource, context);
23
+ return decision.allowed;
24
+ }
25
+ async function assert(actor, action, resource, context) {
26
+ if (!isValidActor(actor)) {
27
+ throw new UnauthorizedError('Authentication required');
28
+ }
29
+ const decision = await evaluate(actor, action, resource, context);
30
+ if (!decision.allowed) {
31
+ // Safe public message: never leak internal policy names or cross-tenant existence
32
+ throw new ForbiddenError('Access denied');
33
+ }
34
+ }
35
+ function hasRole(actor, role) {
36
+ return rbac.hasRole(actor, role);
37
+ }
38
+ function assertRole(actor, role) {
39
+ if (!isValidActor(actor)) {
40
+ throw new UnauthorizedError('Authentication required');
41
+ }
42
+ if (!rbac.hasRole(actor, role)) {
43
+ throw new ForbiddenError('Access denied');
44
+ }
45
+ }
46
+ function hasPermission(actor, permission) {
47
+ return rbac.hasPermission(actor, permission);
48
+ }
49
+ function assertPermission(actor, permission) {
50
+ if (!isValidActor(actor)) {
51
+ throw new UnauthorizedError('Authentication required');
52
+ }
53
+ if (!rbac.hasPermission(actor, permission)) {
54
+ throw new ForbiddenError('Access denied');
55
+ }
56
+ }
57
+ const authorizer = Object.freeze({
58
+ rbac,
59
+ policyEngine,
60
+ evaluate,
61
+ can,
62
+ assert,
63
+ hasRole,
64
+ assertRole,
65
+ hasPermission,
66
+ assertPermission,
67
+ checkOwner: checkOwnership,
68
+ assertOwner: assertOwnership,
69
+ checkTenant: checkTenantIsolation,
70
+ assertTenant: assertTenantIsolation,
71
+ forActor(actor) {
72
+ const bound = {
73
+ actor,
74
+ evaluate: (action, resource, context) => evaluate(actor, action, resource, context),
75
+ can: (action, resource, context) => can(actor, action, resource, context),
76
+ assert: (action, resource, context) => assert(actor, action, resource, context),
77
+ hasRole: (role) => hasRole(actor, role),
78
+ assertRole: (role) => assertRole(actor, role),
79
+ hasPermission: (permission) => hasPermission(actor, permission),
80
+ assertPermission: (permission) => assertPermission(actor, permission),
81
+ assertOwner: (resource, opts) => assertOwnership(actor, resource, opts),
82
+ assertTenant: (resourceOrTenantId, opts) => assertTenantIsolation(actor, resourceOrTenantId, opts),
83
+ };
84
+ return Object.freeze(bound);
85
+ },
86
+ });
87
+ return authorizer;
88
+ }
89
+ //# sourceMappingURL=authorizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizer.js","sourceRoot":"","sources":["../src/authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,kBAAkB,GAGnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,eAAe,EACf,cAAc,GAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,GAGnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,GAIb,MAAM,YAAY,CAAC;AA0FpB,MAAM,UAAU,gBAAgB,CAAC,OAAO,GAAsB,EAAE;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAkB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,kBAAkB,CAAC;QACtC,IAAI;QACJ,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,C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createDecision, isForbiddenKey, isValidActor, type Actor, type AuthorizationAuditEvent, type AuthorizationAuditHook, type AuthorizationDecision, type AuthorizationEffect, } from './types.js';
2
+ export { createRbacRegistry, matchesPermission, type EffectivePermissions, type RbacRegistry, type RoleDefinition, type RoleDefinitionsMap, } from './permissions.js';
3
+ export { assertTenantIsolation, assertTenantParamMatch, checkTenantIsolation, type TenantGuardOptions, type TenantScopedResource, } from './tenant.js';
4
+ export { assertOwnership, checkOwnership, type OwnedResource, type OwnershipOptions, } from './ownership.js';
5
+ export { createPolicyEngine, definePolicy, type PolicyEngine, type PolicyEngineOptions, type PolicyEvaluationInput, type PolicyRule, } from './policy.js';
6
+ export { createAuthorizer, type ActorAuthorizer, type Authorizer, type AuthorizerOptions, } from './authorizer.js';
7
+ export { createAuthorizationMiddleware, requirePermissions, requireRoles, requireTenantParam, type AuthorizationMiddlewareOptions, type PermissionGuardOptions, type RoleGuardOptions, } from './middleware.js';
8
+ export { AuthorizationTokens, createAuthorizationPlugin, type AuthorizationPluginConfig, type AuthorizationPluginOptions, } from './plugin.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,EAChB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { FORBIDDEN_KEYS, actorFromIdentity, createDecision, isForbiddenKey, isValidActor, } from './types.js';
2
+ export { createRbacRegistry, matchesPermission, } from './permissions.js';
3
+ export { assertTenantIsolation, assertTenantParamMatch, checkTenantIsolation, } from './tenant.js';
4
+ export { assertOwnership, checkOwnership, } from './ownership.js';
5
+ export { createPolicyEngine, definePolicy, } from './policy.js';
6
+ export { createAuthorizer, } from './authorizer.js';
7
+ export { createAuthorizationMiddleware, requirePermissions, requireRoles, requireTenantParam, } from './middleware.js';
8
+ export { AuthorizationTokens, createAuthorizationPlugin, } from './plugin.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,YAAY,GAMb,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAKlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GAGrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,eAAe,EACf,cAAc,GAGf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,kBAAkB,EAClB,YAAY,GAKb,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,GAIjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,GAInB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAG1B,MAAM,aAAa,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ForgeContext, ForgeMiddleware } from '@forge-fr/http';
2
+ import { type RbacRegistry } from './permissions.js';
3
+ import { type TenantGuardOptions } from './tenant.js';
4
+ import { type Actor } from './types.js';
5
+ import type { Authorizer } from './authorizer.js';
6
+ export interface RoleGuardOptions {
7
+ readonly mode?: 'any' | 'all';
8
+ readonly rbac?: RbacRegistry;
9
+ }
10
+ export declare function requireRoles(roles: readonly string[], options?: RoleGuardOptions): ForgeMiddleware;
11
+ export interface PermissionGuardOptions {
12
+ readonly mode?: 'any' | 'all';
13
+ readonly rbac?: RbacRegistry;
14
+ }
15
+ export declare function requirePermissions(permissions: readonly string[], options?: PermissionGuardOptions): ForgeMiddleware;
16
+ export declare function requireTenantParam(paramName?: string, options?: Omit<TenantGuardOptions<string>, 'getResourceTenantId'>): ForgeMiddleware;
17
+ export interface AuthorizationMiddlewareOptions<TResource = unknown, TContext = unknown> {
18
+ readonly action: string | ((ctx: ForgeContext) => string);
19
+ readonly loadResource?: (ctx: ForgeContext, actor: Actor) => TResource | Promise<TResource>;
20
+ readonly getContext?: (ctx: ForgeContext, actor: Actor) => TContext | Promise<TContext>;
21
+ /**
22
+ * When true (default when `loadResource` is provided), missing/undefined loaded resources
23
+ * immediately fail closed with ForbiddenError instead of evaluating against undefined.
24
+ */
25
+ readonly denyIfResourceMissing?: boolean;
26
+ }
27
+ export declare function createAuthorizationMiddleware<TResource = unknown, TContext = unknown>(authorizer: Authorizer, options: AuthorizationMiddlewareOptions<TResource, TContext>): ForgeMiddleware;
28
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAYlD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,GAAE,gBAAqB,GAC7B,eAAe,CAgBjB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAkBjB;AAED,wBAAgB,kBAAkB,CAChC,SAAS,SAAa,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,GAChE,eAAe,CAWjB;AAED,MAAM,WAAW,8BAA8B,CAAC,SAAS,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,CAAC;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE,CACtB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,KAAK,KACT,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,CACpB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,KAAK,KACT,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,wBAAgB,6BAA6B,CAAC,SAAS,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,EACnF,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,8BAA8B,CAAC,SAAS,EAAE,QAAQ,CAAC,GAC3D,eAAe,CAoBjB"}
@@ -0,0 +1,74 @@
1
+ import { ConfigurationError, ForbiddenError, UnauthorizedError } from '@forge-fr/core';
2
+ import { getAuth } from '@forge-fr/auth';
3
+ import { createRbacRegistry } from './permissions.js';
4
+ import { assertTenantParamMatch } from './tenant.js';
5
+ import { actorFromIdentity } from './types.js';
6
+ const EMPTY_RBAC = createRbacRegistry();
7
+ function requireActorFromContext(ctx) {
8
+ const identity = getAuth(ctx);
9
+ if (identity === undefined) {
10
+ throw new UnauthorizedError('Authentication required');
11
+ }
12
+ return actorFromIdentity(identity);
13
+ }
14
+ export function requireRoles(roles, options = {}) {
15
+ if (!Array.isArray(roles) || roles.length === 0) {
16
+ throw new ConfigurationError('requireRoles requires at least one role');
17
+ }
18
+ const mode = options.mode ?? 'any';
19
+ const rbac = options.rbac ?? EMPTY_RBAC;
20
+ return async (ctx, next) => {
21
+ const actor = requireActorFromContext(ctx);
22
+ const allowed = mode === 'all' ? rbac.hasAllRoles(actor, roles) : rbac.hasAnyRole(actor, roles);
23
+ if (!allowed) {
24
+ throw new ForbiddenError('Access denied');
25
+ }
26
+ return next();
27
+ };
28
+ }
29
+ export function requirePermissions(permissions, options = {}) {
30
+ if (!Array.isArray(permissions) || permissions.length === 0) {
31
+ throw new ConfigurationError('requirePermissions requires at least one permission');
32
+ }
33
+ const mode = options.mode ?? 'all';
34
+ const rbac = options.rbac ?? EMPTY_RBAC;
35
+ return async (ctx, next) => {
36
+ const actor = requireActorFromContext(ctx);
37
+ const allowed = mode === 'any'
38
+ ? rbac.hasAnyPermission(actor, permissions)
39
+ : rbac.hasAllPermissions(actor, permissions);
40
+ if (!allowed) {
41
+ throw new ForbiddenError('Access denied');
42
+ }
43
+ return next();
44
+ };
45
+ }
46
+ export function requireTenantParam(paramName = 'tenantId', options) {
47
+ if (typeof paramName !== 'string' || paramName.trim().length === 0) {
48
+ throw new ConfigurationError('requireTenantParam requires a non-empty paramName');
49
+ }
50
+ return async (ctx, next) => {
51
+ const actor = requireActorFromContext(ctx);
52
+ const requestedTenantId = ctx.params[paramName];
53
+ assertTenantParamMatch(actor, requestedTenantId, options);
54
+ return next();
55
+ };
56
+ }
57
+ export function createAuthorizationMiddleware(authorizer, options) {
58
+ return async (ctx, next) => {
59
+ const actor = requireActorFromContext(ctx);
60
+ const action = typeof options.action === 'function' ? options.action(ctx) : options.action;
61
+ let resource;
62
+ if (options.loadResource !== undefined) {
63
+ resource = await options.loadResource(ctx, actor);
64
+ const denyIfMissing = options.denyIfResourceMissing ?? true;
65
+ if (denyIfMissing && (resource === undefined || resource === null)) {
66
+ throw new ForbiddenError('Access denied');
67
+ }
68
+ }
69
+ const extraContext = options.getContext !== undefined ? await options.getContext(ctx, actor) : undefined;
70
+ await authorizer.assert(actor, action, resource, extraContext);
71
+ return next();
72
+ };
73
+ }
74
+ //# sourceMappingURL=middleware.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tF,MAAM,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC/D,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type Actor, type AuthorizationDecision } from './types.js';
2
+ import { type TenantScopedResource } from './tenant.js';
3
+ export interface OwnedResource extends TenantScopedResource {
4
+ readonly ownerId?: string | number | null;
5
+ readonly userId?: string | number | null;
6
+ readonly createdBy?: string | number | null;
7
+ }
8
+ export interface OwnershipOptions<TResource = OwnedResource> {
9
+ /** Custom extractor for resource owner subject ID. */
10
+ readonly getOwnerId?: (resource: TResource) => string | number | null | undefined;
11
+ /** Custom extractor for resource tenant ID. */
12
+ readonly getResourceTenantId?: (resource: TResource) => string | number | null | undefined;
13
+ /**
14
+ * Enforces tenant match alongside ownership whenever a resource carries tenantId
15
+ * (defaults to `true` to prevent cross-tenant admin IDOR).
16
+ */
17
+ readonly requireTenantMatch?: boolean;
18
+ /** Roles allowed to bypass individual ownership (still tenant-scoped when requireTenantMatch is true). */
19
+ readonly bypassRoles?: readonly string[];
20
+ /** Explicit cross-tenant system bypass predicate. */
21
+ readonly allowSystemBypass?: (actor: Actor) => boolean;
22
+ /** Custom forbidden error message (defaults to 'Access denied'). */
23
+ readonly message?: string;
24
+ }
25
+ export declare function checkOwnership<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): AuthorizationDecision;
26
+ export declare function assertOwnership<TResource = OwnedResource>(actor: Actor | null | undefined, resource: TResource | null | undefined, options?: OwnershipOptions<TResource>): void;
27
+ //# sourceMappingURL=ownership.d.ts.map
@@ -0,0 +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,OA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AG,IAAI,GAAG,SAAS,EAC/B,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,GACpC,IAAI,CASN"}
@@ -0,0 +1,81 @@
1
+ import { ForbiddenError, UnauthorizedError } from '@forge-fr/core';
2
+ import { createDecision, isValidActor, } from './types.js';
3
+ import { checkTenantIsolation } from './tenant.js';
4
+ function normalizeId(value) {
5
+ if (typeof value === 'number' && Number.isFinite(value)) {
6
+ return String(value);
7
+ }
8
+ if (typeof value !== 'string') {
9
+ return null;
10
+ }
11
+ const trimmed = value.trim();
12
+ return trimmed.length > 0 ? trimmed : null;
13
+ }
14
+ function resolveOwnerId(resource, options) {
15
+ if (options?.getOwnerId !== undefined) {
16
+ return normalizeId(options.getOwnerId(resource));
17
+ }
18
+ if (resource !== null && typeof resource === 'object') {
19
+ const owned = resource;
20
+ return (normalizeId(owned.ownerId) ??
21
+ normalizeId(owned.userId) ??
22
+ normalizeId(owned.createdBy));
23
+ }
24
+ return null;
25
+ }
26
+ function hasTenantField(resource, options) {
27
+ if (options?.getResourceTenantId !== undefined) {
28
+ return options.getResourceTenantId(resource) !== undefined;
29
+ }
30
+ return (resource !== null &&
31
+ typeof resource === 'object' &&
32
+ 'tenantId' in resource &&
33
+ resource.tenantId !== undefined);
34
+ }
35
+ export function checkOwnership(actor, resource, options) {
36
+ if (!isValidActor(actor)) {
37
+ return createDecision(false, 'Unauthenticated actor');
38
+ }
39
+ if (resource === null || resource === undefined) {
40
+ return createDecision(false, 'Target resource is missing');
41
+ }
42
+ const enforceTenant = options?.requireTenantMatch ?? hasTenantField(resource, options);
43
+ if (enforceTenant) {
44
+ const tenantDecision = checkTenantIsolation(actor, resource, {
45
+ ...(options?.getResourceTenantId !== undefined
46
+ ? { getResourceTenantId: options.getResourceTenantId }
47
+ : {}),
48
+ ...(options?.allowSystemBypass !== undefined
49
+ ? { allowSystemBypass: options.allowSystemBypass }
50
+ : {}),
51
+ });
52
+ if (!tenantDecision.allowed) {
53
+ return tenantDecision;
54
+ }
55
+ }
56
+ if (options?.bypassRoles !== undefined && options.bypassRoles.length > 0) {
57
+ const hasBypass = options.bypassRoles.some((role) => actor.roles.includes(role));
58
+ if (hasBypass) {
59
+ return createDecision(true, 'Ownership bypassed by authorized role', 'ownership:role-bypass');
60
+ }
61
+ }
62
+ const ownerId = resolveOwnerId(resource, options);
63
+ if (ownerId === null) {
64
+ return createDecision(false, 'Resource has no owner');
65
+ }
66
+ const actorSubject = normalizeId(actor.subject);
67
+ if (actorSubject === null || actorSubject !== ownerId) {
68
+ return createDecision(false, 'Actor does not own resource');
69
+ }
70
+ return createDecision(true, 'Resource ownership verified', 'ownership:match');
71
+ }
72
+ export function assertOwnership(actor, resource, options) {
73
+ if (!isValidActor(actor)) {
74
+ throw new UnauthorizedError('Authentication required');
75
+ }
76
+ const decision = checkOwnership(actor, resource, options);
77
+ if (!decision.allowed) {
78
+ throw new ForbiddenError(options?.message ?? 'Access denied');
79
+ }
80
+ }
81
+ //# sourceMappingURL=ownership.js.map
@@ -0,0 +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;AA0B9E,SAAS,WAAW,CAAC,KAAc;IACjC,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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C,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"}
@@ -0,0 +1,33 @@
1
+ import { type Actor } from './types.js';
2
+ export interface RoleDefinition {
3
+ readonly permissions: readonly string[];
4
+ readonly deniedPermissions?: readonly string[];
5
+ readonly inherits?: readonly string[];
6
+ }
7
+ export type RoleDefinitionsMap = Readonly<Record<string, RoleDefinition>>;
8
+ export interface EffectivePermissions {
9
+ readonly roles: ReadonlySet<string>;
10
+ readonly allowed: readonly string[];
11
+ readonly denied: readonly string[];
12
+ }
13
+ export interface RbacRegistry {
14
+ readonly roleNames: readonly string[];
15
+ resolve(actor: Actor | null | undefined): EffectivePermissions;
16
+ hasRole(actor: Actor | null | undefined, role: string): boolean;
17
+ hasAnyRole(actor: Actor | null | undefined, roles: readonly string[]): boolean;
18
+ hasAllRoles(actor: Actor | null | undefined, roles: readonly string[]): boolean;
19
+ hasPermission(actor: Actor | null | undefined, permission: string): boolean;
20
+ hasAnyPermission(actor: Actor | null | undefined, permissions: readonly string[]): boolean;
21
+ hasAllPermissions(actor: Actor | null | undefined, permissions: readonly string[]): boolean;
22
+ }
23
+ /**
24
+ * Segment-strict permission matcher using ':' as delimiter.
25
+ * Supports:
26
+ * - exact match (`invoice:read`)
27
+ * - single-segment wildcard (`invoice:*`, `*:read`, `org:*:read`)
28
+ * - multi-segment tail wildcard (`invoice:**`)
29
+ * - global wildcard (`*`)
30
+ */
31
+ export declare function matchesPermission(granted: string, required: string): boolean;
32
+ export declare function createRbacRegistry(definitions?: RoleDefinitionsMap): RbacRegistry;
33
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAE1E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,CAAC;IAC/D,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,I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