@spinajs/authz-fs 0.0.0-stage → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/lib/cjs/access-config/acl-config.d.ts +23 -0
- package/lib/cjs/access-config/acl-config.d.ts.map +1 -0
- package/lib/cjs/access-config/acl-config.js +36 -0
- package/lib/cjs/access-config/acl-config.js.map +1 -0
- package/lib/cjs/access-config/index.d.ts +34 -0
- package/lib/cjs/access-config/index.d.ts.map +1 -0
- package/lib/cjs/access-config/index.js +89 -0
- package/lib/cjs/access-config/index.js.map +1 -0
- package/lib/cjs/access-config/schema.d.ts +31 -0
- package/lib/cjs/access-config/schema.d.ts.map +1 -0
- package/lib/cjs/access-config/schema.js +55 -0
- package/lib/cjs/access-config/schema.js.map +1 -0
- package/lib/cjs/acl/facade.d.ts +39 -0
- package/lib/cjs/acl/facade.d.ts.map +1 -0
- package/lib/cjs/acl/facade.js +73 -0
- package/lib/cjs/acl/facade.js.map +1 -0
- package/lib/cjs/acl/index.d.ts +6 -0
- package/lib/cjs/acl/index.d.ts.map +1 -0
- package/lib/cjs/acl/index.js +25 -0
- package/lib/cjs/acl/index.js.map +1 -0
- package/lib/cjs/acl/orm-store.d.ts +31 -0
- package/lib/cjs/acl/orm-store.d.ts.map +1 -0
- package/lib/cjs/acl/orm-store.js +199 -0
- package/lib/cjs/acl/orm-store.js.map +1 -0
- package/lib/cjs/acl/relation.d.ts +29 -0
- package/lib/cjs/acl/relation.d.ts.map +1 -0
- package/lib/cjs/acl/relation.js +60 -0
- package/lib/cjs/acl/relation.js.map +1 -0
- package/lib/cjs/acl/shared.d.ts +36 -0
- package/lib/cjs/acl/shared.d.ts.map +1 -0
- package/lib/cjs/acl/shared.js +91 -0
- package/lib/cjs/acl/shared.js.map +1 -0
- package/lib/cjs/acl/store.d.ts +43 -0
- package/lib/cjs/acl/store.d.ts.map +1 -0
- package/lib/cjs/acl/store.js +12 -0
- package/lib/cjs/acl/store.js.map +1 -0
- package/lib/cjs/adapter/index.d.ts +33 -0
- package/lib/cjs/adapter/index.d.ts.map +1 -0
- package/lib/cjs/adapter/index.js +76 -0
- package/lib/cjs/adapter/index.js.map +1 -0
- package/lib/cjs/checks.d.ts +5 -0
- package/lib/cjs/checks.d.ts.map +1 -0
- package/lib/cjs/checks.js +20 -0
- package/lib/cjs/checks.js.map +1 -0
- package/lib/cjs/http/from-fs-path.d.ts +15 -0
- package/lib/cjs/http/from-fs-path.d.ts.map +1 -0
- package/lib/cjs/http/from-fs-path.js +43 -0
- package/lib/cjs/http/from-fs-path.js.map +1 -0
- package/lib/cjs/http/index.d.ts +3 -0
- package/lib/cjs/http/index.d.ts.map +1 -0
- package/lib/cjs/http/index.js +19 -0
- package/lib/cjs/http/index.js.map +1 -0
- package/lib/cjs/http/upload.d.ts +29 -0
- package/lib/cjs/http/upload.d.ts.map +1 -0
- package/lib/cjs/http/upload.js +67 -0
- package/lib/cjs/http/upload.js.map +1 -0
- package/lib/cjs/index.d.ts +9 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +25 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/middleware/decide.d.ts +32 -0
- package/lib/cjs/middleware/decide.d.ts.map +1 -0
- package/lib/cjs/middleware/decide.js +51 -0
- package/lib/cjs/middleware/decide.js.map +1 -0
- package/lib/cjs/middleware/index.d.ts +53 -0
- package/lib/cjs/middleware/index.d.ts.map +1 -0
- package/lib/cjs/middleware/index.js +236 -0
- package/lib/cjs/middleware/index.js.map +1 -0
- package/lib/cjs/middleware/owner.d.ts +10 -0
- package/lib/cjs/middleware/owner.d.ts.map +1 -0
- package/lib/cjs/middleware/owner.js +20 -0
- package/lib/cjs/middleware/owner.js.map +1 -0
- package/lib/cjs/middleware/signed-url.d.ts +22 -0
- package/lib/cjs/middleware/signed-url.d.ts.map +1 -0
- package/lib/cjs/middleware/signed-url.js +36 -0
- package/lib/cjs/middleware/signed-url.js.map +1 -0
- package/lib/cjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.d.ts +8 -0
- package/lib/cjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.d.ts.map +1 -0
- package/lib/cjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.js +45 -0
- package/lib/cjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.js.map +1 -0
- package/lib/cjs/migrations/index.d.ts +2 -0
- package/lib/cjs/migrations/index.d.ts.map +1 -0
- package/lib/cjs/migrations/index.js +18 -0
- package/lib/cjs/migrations/index.js.map +1 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/permissions/index.d.ts +3 -0
- package/lib/cjs/permissions/index.d.ts.map +1 -0
- package/lib/cjs/permissions/index.js +7 -0
- package/lib/cjs/permissions/index.js.map +1 -0
- package/lib/cjs/refs/index.d.ts +3 -0
- package/lib/cjs/refs/index.d.ts.map +1 -0
- package/lib/cjs/refs/index.js +21 -0
- package/lib/cjs/refs/index.js.map +1 -0
- package/lib/cjs/refs/refs.d.ts +34 -0
- package/lib/cjs/refs/refs.d.ts.map +1 -0
- package/lib/cjs/refs/refs.js +79 -0
- package/lib/cjs/refs/refs.js.map +1 -0
- package/lib/mjs/access-config/acl-config.d.ts +23 -0
- package/lib/mjs/access-config/acl-config.d.ts.map +1 -0
- package/lib/mjs/access-config/acl-config.js +32 -0
- package/lib/mjs/access-config/acl-config.js.map +1 -0
- package/lib/mjs/access-config/index.d.ts +34 -0
- package/lib/mjs/access-config/index.d.ts.map +1 -0
- package/lib/mjs/access-config/index.js +71 -0
- package/lib/mjs/access-config/index.js.map +1 -0
- package/lib/mjs/access-config/schema.d.ts +31 -0
- package/lib/mjs/access-config/schema.d.ts.map +1 -0
- package/lib/mjs/access-config/schema.js +52 -0
- package/lib/mjs/access-config/schema.js.map +1 -0
- package/lib/mjs/acl/facade.d.ts +39 -0
- package/lib/mjs/acl/facade.d.ts.map +1 -0
- package/lib/mjs/acl/facade.js +69 -0
- package/lib/mjs/acl/facade.js.map +1 -0
- package/lib/mjs/acl/index.d.ts +6 -0
- package/lib/mjs/acl/index.d.ts.map +1 -0
- package/lib/mjs/acl/index.js +6 -0
- package/lib/mjs/acl/index.js.map +1 -0
- package/lib/mjs/acl/orm-store.d.ts +31 -0
- package/lib/mjs/acl/orm-store.d.ts.map +1 -0
- package/lib/mjs/acl/orm-store.js +196 -0
- package/lib/mjs/acl/orm-store.js.map +1 -0
- package/lib/mjs/acl/relation.d.ts +29 -0
- package/lib/mjs/acl/relation.d.ts.map +1 -0
- package/lib/mjs/acl/relation.js +56 -0
- package/lib/mjs/acl/relation.js.map +1 -0
- package/lib/mjs/acl/shared.d.ts +36 -0
- package/lib/mjs/acl/shared.d.ts.map +1 -0
- package/lib/mjs/acl/shared.js +73 -0
- package/lib/mjs/acl/shared.js.map +1 -0
- package/lib/mjs/acl/store.d.ts +43 -0
- package/lib/mjs/acl/store.d.ts.map +1 -0
- package/lib/mjs/acl/store.js +8 -0
- package/lib/mjs/acl/store.js.map +1 -0
- package/lib/mjs/adapter/index.d.ts +33 -0
- package/lib/mjs/adapter/index.d.ts.map +1 -0
- package/lib/mjs/adapter/index.js +73 -0
- package/lib/mjs/adapter/index.js.map +1 -0
- package/lib/mjs/checks.d.ts +5 -0
- package/lib/mjs/checks.d.ts.map +1 -0
- package/lib/mjs/checks.js +16 -0
- package/lib/mjs/checks.js.map +1 -0
- package/lib/mjs/http/from-fs-path.d.ts +15 -0
- package/lib/mjs/http/from-fs-path.d.ts.map +1 -0
- package/lib/mjs/http/from-fs-path.js +40 -0
- package/lib/mjs/http/from-fs-path.js.map +1 -0
- package/lib/mjs/http/index.d.ts +3 -0
- package/lib/mjs/http/index.d.ts.map +1 -0
- package/lib/mjs/http/index.js +3 -0
- package/lib/mjs/http/index.js.map +1 -0
- package/lib/mjs/http/upload.d.ts +29 -0
- package/lib/mjs/http/upload.d.ts.map +1 -0
- package/lib/mjs/http/upload.js +64 -0
- package/lib/mjs/http/upload.js.map +1 -0
- package/lib/mjs/index.d.ts +9 -0
- package/lib/mjs/index.d.ts.map +1 -0
- package/lib/mjs/index.js +9 -0
- package/lib/mjs/index.js.map +1 -0
- package/lib/mjs/middleware/decide.d.ts +32 -0
- package/lib/mjs/middleware/decide.d.ts.map +1 -0
- package/lib/mjs/middleware/decide.js +42 -0
- package/lib/mjs/middleware/decide.js.map +1 -0
- package/lib/mjs/middleware/index.d.ts +53 -0
- package/lib/mjs/middleware/index.d.ts.map +1 -0
- package/lib/mjs/middleware/index.js +231 -0
- package/lib/mjs/middleware/index.js.map +1 -0
- package/lib/mjs/middleware/owner.d.ts +10 -0
- package/lib/mjs/middleware/owner.d.ts.map +1 -0
- package/lib/mjs/middleware/owner.js +16 -0
- package/lib/mjs/middleware/owner.js.map +1 -0
- package/lib/mjs/middleware/signed-url.d.ts +22 -0
- package/lib/mjs/middleware/signed-url.d.ts.map +1 -0
- package/lib/mjs/middleware/signed-url.js +31 -0
- package/lib/mjs/middleware/signed-url.js.map +1 -0
- package/lib/mjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.d.ts +8 -0
- package/lib/mjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.d.ts.map +1 -0
- package/lib/mjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.js +42 -0
- package/lib/mjs/migrations/AuthzFsAcl_2026_10_17_00_00_00.js.map +1 -0
- package/lib/mjs/migrations/index.d.ts +2 -0
- package/lib/mjs/migrations/index.d.ts.map +1 -0
- package/lib/mjs/migrations/index.js +2 -0
- package/lib/mjs/migrations/index.js.map +1 -0
- package/lib/mjs/package.json +1 -0
- package/lib/mjs/permissions/index.d.ts +3 -0
- package/lib/mjs/permissions/index.d.ts.map +1 -0
- package/lib/mjs/permissions/index.js +4 -0
- package/lib/mjs/permissions/index.js.map +1 -0
- package/lib/mjs/refs/index.d.ts +3 -0
- package/lib/mjs/refs/index.d.ts.map +1 -0
- package/lib/mjs/refs/index.js +3 -0
- package/lib/mjs/refs/index.js.map +1 -0
- package/lib/mjs/refs/refs.d.ts +34 -0
- package/lib/mjs/refs/refs.d.ts.map +1 -0
- package/lib/mjs/refs/refs.js +71 -0
- package/lib/mjs/refs/refs.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/tsconfig.mjs.tsbuildinfo +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FsResourceAdapter = void 0;
|
|
13
|
+
const authz_1 = require("@spinajs/authz");
|
|
14
|
+
const di_1 = require("@spinajs/di");
|
|
15
|
+
const fs_1 = require("@spinajs/fs");
|
|
16
|
+
const index_js_1 = require("../access-config/index.js");
|
|
17
|
+
const relation_js_1 = require("../acl/relation.js");
|
|
18
|
+
const index_js_2 = require("../permissions/index.js");
|
|
19
|
+
const index_js_3 = require("../refs/index.js");
|
|
20
|
+
const isKind = (v) => v === 'file' || v === 'dir';
|
|
21
|
+
/** Refs, ancestors, rows and permissions of the filesystems; registered in the root container. */
|
|
22
|
+
let FsResourceAdapter = class FsResourceAdapter extends authz_1.ResourceAdapter {
|
|
23
|
+
/** Where the published fs providers and the Configuration are looked up. */
|
|
24
|
+
constructor(container = di_1.DI.RootContainer) {
|
|
25
|
+
super();
|
|
26
|
+
this.container = container;
|
|
27
|
+
this.kind = 'fs';
|
|
28
|
+
this.types = index_js_3.FS_RESOURCE_TYPES;
|
|
29
|
+
}
|
|
30
|
+
accepts(target) {
|
|
31
|
+
if (target === null || typeof target !== 'object')
|
|
32
|
+
return false;
|
|
33
|
+
const proto = Object.getPrototypeOf(target);
|
|
34
|
+
if (proto !== Object.prototype && proto !== null)
|
|
35
|
+
return false;
|
|
36
|
+
const t = target;
|
|
37
|
+
return typeof t.fs === 'string' && typeof t.path === 'string' && (t.kind === undefined || isKind(t.kind));
|
|
38
|
+
}
|
|
39
|
+
refOf(target) {
|
|
40
|
+
const type = target.type;
|
|
41
|
+
return (0, index_js_3.fsRef)(target.fs, (0, index_js_3.normalizeFsPath)(target.path, this.basePathOf(target.fs)), target.kind ?? (type === 'dir' ? 'dir' : 'file'));
|
|
42
|
+
}
|
|
43
|
+
/** Does not know which filesystems exist, so an fs name with no provider still gets a chain (it grants nothing). */
|
|
44
|
+
async ancestors(ref) {
|
|
45
|
+
return (0, index_js_3.fsAncestors)(ref);
|
|
46
|
+
}
|
|
47
|
+
/** The row AuthzFsMiddleware passes as the subject of every check, built without IO. */
|
|
48
|
+
async load(ref) {
|
|
49
|
+
return (0, index_js_3.fsRow)(ref);
|
|
50
|
+
}
|
|
51
|
+
attribute(subject, field) {
|
|
52
|
+
return subject !== null && typeof subject === 'object' && Object.hasOwn(subject, field) ? subject[field] : undefined;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One FsAclRelation per fs type and `authz.fsAcl` relation: boot rule 8 needs a resolver for every relation a grant
|
|
56
|
+
* names, on every type of the permission, known at boot.
|
|
57
|
+
*/
|
|
58
|
+
relations() {
|
|
59
|
+
const { relations } = (0, index_js_1.fsAclConfig)(this.container);
|
|
60
|
+
return Object.freeze(index_js_3.FS_RESOURCE_TYPES.flatMap((type) => relations.map((relation) => new relation_js_1.FsAclRelation(type, relation, this.container))));
|
|
61
|
+
}
|
|
62
|
+
permissions() {
|
|
63
|
+
return index_js_2.FS_PERMISSIONS;
|
|
64
|
+
}
|
|
65
|
+
// Read from the published provider, so refOf does no IO.
|
|
66
|
+
basePathOf(fsName) {
|
|
67
|
+
const basePath = (0, fs_1.publishedFs)(fsName, this.container)?.BasePath;
|
|
68
|
+
return typeof basePath === 'string' && basePath !== '' ? basePath : undefined;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.FsResourceAdapter = FsResourceAdapter;
|
|
72
|
+
exports.FsResourceAdapter = FsResourceAdapter = __decorate([
|
|
73
|
+
(0, di_1.Injectable)(authz_1.ResourceAdapter),
|
|
74
|
+
__metadata("design:paramtypes", [Object])
|
|
75
|
+
], FsResourceAdapter);
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAiD;AAEjD,oCAA6C;AAE7C,oCAA0C;AAE1C,wDAAwD;AACxD,oDAAmD;AACnD,sDAAyD;AACzD,+CAAiG;AAUjG,MAAM,MAAM,GAAG,CAAC,CAAU,EAAmB,EAAE,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,CAAC;AAE5E,kGAAkG;AAE3F,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,uBAAiC;IAItE,4EAA4E;IAC5E,YAA+B,SAAS,GAAe,OAAE,CAAC,aAAa;QACrE,KAAK,EAAE,CAAC;QADqB,cAAS,GAAT,SAAS,CAA+B;QAJ9D,SAAI,GAAG,IAAI,CAAC;QACZ,UAAK,GAA4B,4BAAiB,CAAC;IAK5D,CAAC;IAED,OAAO,CAAC,MAAe;QACrB,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAA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CAAC;IAED;;;OAGG;IACH,SAAS;QACP,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,MAAM,CAAC,4BAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,2BAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5I,CAAC;IAED,WAAW;QACT,OAAO,yBAAc,CAAC;IACxB,CAAC;IAED,yDAAyD;IAC/C,UAAU,CAAC,MAAc;QACjC,MAAM,QAAQ,GAAG,IAAA,gBAAW,EAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;QAC/D,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAChF,CAAC;CACF,CAAA;;4BAtDY,iBAAiB;IAD7B,IAAA,eAAU,EAAC,uBAAe,CAAC;;GACf,iBAAiB,CAsD7B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** A non-empty filesystem name without ':' (the first ':' of a ref id ends the name). */
|
|
2
|
+
export declare function checkFsName(fsName: unknown): string;
|
|
3
|
+
/** `value` as JSON for an error message; a value JSON cannot hold gives its String or its tag. */
|
|
4
|
+
export declare function show(value: unknown): string;
|
|
5
|
+
//# sourceMappingURL=checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/checks.ts"],"names":[],"mappings":"AAIA,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED,kGAAkG;AAClG,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM3C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkFsName = checkFsName;
|
|
4
|
+
exports.show = show;
|
|
5
|
+
const util_1 = require("@spinajs/util");
|
|
6
|
+
// Internal: the barrel does not export this module.
|
|
7
|
+
/** A non-empty filesystem name without ':' (the first ':' of a ref id ends the name). */
|
|
8
|
+
function checkFsName(fsName) {
|
|
9
|
+
return (0, util_1._check_arg)((0, util_1._is_string)((0, util_1._non_empty)(), (0, util_1._reg_match)(/^[^:]*$/)))(fsName, 'fsName');
|
|
10
|
+
}
|
|
11
|
+
/** `value` as JSON for an error message; a value JSON cannot hold gives its String or its tag. */
|
|
12
|
+
function show(value) {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.stringify(value) ?? String(value);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return Object.prototype.toString.call(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/checks.ts"],"names":[],"mappings":";;;;AAAA,wCAA+E;AAE/E,oDAAoD;AAEpD,yFAAyF;AACzF,qBAA4B,MAAe;IACzC,OAAO,IAAA,iBAAU,EAAC,IAAA,iBAAU,EAAC,IAAA,iBAAU,GAAE,EAAE,IAAA,iBAAU,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACvF,CAAC;AAED,kGAAkG;AAClG,cAAqB,KAAc;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ResourceRef } from '@spinajs/authz';
|
|
2
|
+
import type { IContainer } from '@spinajs/di';
|
|
3
|
+
/**
|
|
4
|
+
* A resource extractor for `@Access` (authz-http's `ResourceExtractor`): the `file` ref of the url parameter
|
|
5
|
+
* `param` on `fsName`, the `fs` ref for the root. The path is normalised as the fs core does (D3), with the base
|
|
6
|
+
* path of the published provider, so the ref is the one AuthzFsMiddleware checks for the same path. Only url
|
|
7
|
+
* parameters are read, as authz-http's `fromParam` does. An Express 5 wildcard (`*path`) gives an array of
|
|
8
|
+
* segments: they are joined with '/', each segment refused on its own when the normaliser refuses it (`..` included).
|
|
9
|
+
*
|
|
10
|
+
* @param container - where the published provider is looked up; default the root container
|
|
11
|
+
* @throws InvalidArgument (400) when the parameter is missing, not a string or a non-empty string array, or the
|
|
12
|
+
* path is refused
|
|
13
|
+
*/
|
|
14
|
+
export declare function fromFsPath(fsName: string, param: string, container?: IContainer): (req: unknown) => ResourceRef | Promise<ResourceRef>;
|
|
15
|
+
//# sourceMappingURL=from-fs-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-fs-path.d.ts","sourceRoot":"","sources":["../../../src/http/from-fs-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAS9C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAStI"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromFsPath = fromFsPath;
|
|
4
|
+
const di_1 = require("@spinajs/di");
|
|
5
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
6
|
+
const fs_1 = require("@spinajs/fs");
|
|
7
|
+
const util_1 = require("@spinajs/util");
|
|
8
|
+
const checks_js_1 = require("../checks.js");
|
|
9
|
+
const decide_js_1 = require("../middleware/decide.js");
|
|
10
|
+
const index_js_1 = require("../refs/index.js");
|
|
11
|
+
/**
|
|
12
|
+
* A resource extractor for `@Access` (authz-http's `ResourceExtractor`): the `file` ref of the url parameter
|
|
13
|
+
* `param` on `fsName`, the `fs` ref for the root. The path is normalised as the fs core does (D3), with the base
|
|
14
|
+
* path of the published provider, so the ref is the one AuthzFsMiddleware checks for the same path. Only url
|
|
15
|
+
* parameters are read, as authz-http's `fromParam` does. An Express 5 wildcard (`*path`) gives an array of
|
|
16
|
+
* segments: they are joined with '/', each segment refused on its own when the normaliser refuses it (`..` included).
|
|
17
|
+
*
|
|
18
|
+
* @param container - where the published provider is looked up; default the root container
|
|
19
|
+
* @throws InvalidArgument (400) when the parameter is missing, not a string or a non-empty string array, or the
|
|
20
|
+
* path is refused
|
|
21
|
+
*/
|
|
22
|
+
function fromFsPath(fsName, param, container) {
|
|
23
|
+
(0, checks_js_1.checkFsName)(fsName);
|
|
24
|
+
(0, util_1._check_arg)((0, util_1._is_string)((0, util_1._non_empty)()))(param, 'param');
|
|
25
|
+
return (req) => {
|
|
26
|
+
const params = req !== null && typeof req === 'object' ? req.params : undefined;
|
|
27
|
+
const value = params !== null && typeof params === 'object' && Object.hasOwn(params, param) ? params[param] : undefined;
|
|
28
|
+
return (0, decide_js_1.refOf)(fsName, (0, index_js_1.normalizeFsPath)(pathOf(value, param, fsName), (0, fs_1.publishedFs)(fsName, container ?? di_1.DI.RootContainer)?.BasePath), 'file');
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function pathOf(value, param, fsName) {
|
|
32
|
+
if (typeof value === 'string')
|
|
33
|
+
return value;
|
|
34
|
+
if ((0, util_1.isStringArray)(value) && value.length > 0) {
|
|
35
|
+
// A segment such as '..' is refused even where the joined path would stay inside the filesystem.
|
|
36
|
+
for (const segment of value)
|
|
37
|
+
if (segment === '' || segment.includes('/') || (0, index_js_1.normalizeFsPath)(segment) !== segment)
|
|
38
|
+
throw new exceptions_1.InvalidArgument(`url parameter ${param} has the segment ${JSON.stringify(segment)}`, param);
|
|
39
|
+
return value.join('/');
|
|
40
|
+
}
|
|
41
|
+
throw new exceptions_1.InvalidArgument(`url parameter ${param} is required to identify a file of ${fsName}`, param);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=from-fs-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-fs-path.js","sourceRoot":"","sources":["../../../src/http/from-fs-path.ts"],"names":[],"mappings":";;;AACA,oCAAiC;AAEjC,oDAAsD;AACtD,oCAA0C;AAC1C,wCAAkF;AAElF,4CAA2C;AAC3C,uDAAgD;AAChD,+CAAmD;AAEnD;;;;;;;;;;GAUG;AACH,oBAA2B,MAAc,EAAE,KAAa,EAAE,SAAsB;IAC9E,IAAA,uBAAW,EAAC,MAAM,CAAC,CAAC;IACpB,IAAA,iBAAU,EAAC,IAAA,iBAAU,EAAC,IAAA,iBAAU,GAAE,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,GAAY,EAAe,EAAE;QACnC,MAAM,MAAM,GAAY,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAE,GAA4B,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QACnH,MAAM,KAAK,GAAY,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAE,MAAkC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9J,OAAO,IAAA,iBAAK,EAAC,MAAM,EAAE,IAAA,0BAAe,EAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,IAAA,gBAAW,EAAC,MAAM,EAAE,SAAS,IAAI,OAAE,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5I,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAc,EAAE,KAAa,EAAE,MAAc;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,IAAA,oBAAa,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,iGAAiG;QACjG,KAAK,MAAM,OAAO,IAAI,KAAiB;YAAE,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,0BAAe,EAAC,OAAO,CAAC,KAAK,OAAO;gBAAE,MAAM,IAAI,4BAAe,CAAC,iBAAiB,KAAK,oBAAoB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACpO,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,4BAAe,CAAC,iBAAiB,KAAK,sCAAsC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./upload.js"), exports);
|
|
18
|
+
__exportStar(require("./from-fs-path.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,oDAAkC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Principal } from '@spinajs/authz';
|
|
2
|
+
import type { IContainer } from '@spinajs/di';
|
|
3
|
+
import { FileUploadMiddleware } from '@spinajs/http';
|
|
4
|
+
import type { IUploadOptions, IUploadedFile } from '@spinajs/http';
|
|
5
|
+
import type { FsDecideService, FsLog } from '../middleware/decide.js';
|
|
6
|
+
/** The filesystem `FromFile` uploads to when the route names none. */
|
|
7
|
+
export declare const DEFAULT_UPLOAD_FS = "__file_upload_default_provider__";
|
|
8
|
+
export interface AuthzUploadMiddlewareOptions {
|
|
9
|
+
/** Where the Configuration, the published providers and AuthzDomains are resolved; default the root. */
|
|
10
|
+
readonly container?: IContainer;
|
|
11
|
+
/** The service that decides for a domain; default the root AuthzService, else `AuthzDomains.service(domain)`. */
|
|
12
|
+
readonly service?: (domain: string) => Promise<FsDecideService>;
|
|
13
|
+
/** Default: the ALS principal, else UNATTENDED (what AuthzService.current() returns). */
|
|
14
|
+
readonly principal?: () => Principal;
|
|
15
|
+
readonly log?: FsLog;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks `fs:write` on the file an upload will be written to (`file.Provider`, else `options.fs`, else the default
|
|
19
|
+
* upload filesystem, at `file.BaseName`) before the uploader copies it, with that filesystem's mode and domain:
|
|
20
|
+
* enforce refuses with AccessDenied (403) so the formidable temp file is never copied, audit warns, off does
|
|
21
|
+
* nothing. AuthzFsMiddleware checks the copy again, but the uploader turns its denial into an IOFail (500); this
|
|
22
|
+
* gives the 403. Apps add it after middlewares that rename the file.
|
|
23
|
+
*/
|
|
24
|
+
export declare class AuthzUploadMiddleware extends FileUploadMiddleware {
|
|
25
|
+
protected readonly options: AuthzUploadMiddlewareOptions;
|
|
26
|
+
constructor(options?: AuthzUploadMiddlewareOptions);
|
|
27
|
+
beforeUpload(file: IUploadedFile, options?: IUploadOptions): Promise<IUploadedFile>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/http/upload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInE,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGtE,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AAEpE,MAAM,WAAW,4BAA4B;IAC3C,wGAAwG;IACxG,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;IAChC,iHAAiH;IACjH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAChE,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,SAAS,CAAC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;CACtB;AAED;;;;;;GAMG;AACH,qBACa,qBAAsB,SAAQ,oBAAoB;IACjD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,4BAA4B;IAApE,YAA+B,OAAO,GAAE,4BAAiC,EAExE;IAEY,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB/F;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthzUploadMiddleware = exports.DEFAULT_UPLOAD_FS = void 0;
|
|
13
|
+
const authz_1 = require("@spinajs/authz");
|
|
14
|
+
const di_1 = require("@spinajs/di");
|
|
15
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
16
|
+
const fs_1 = require("@spinajs/fs");
|
|
17
|
+
const http_1 = require("@spinajs/http");
|
|
18
|
+
const index_js_1 = require("../access-config/index.js");
|
|
19
|
+
const decide_js_1 = require("../middleware/decide.js");
|
|
20
|
+
const index_js_2 = require("../refs/index.js");
|
|
21
|
+
/** The filesystem `FromFile` uploads to when the route names none. */
|
|
22
|
+
exports.DEFAULT_UPLOAD_FS = '__file_upload_default_provider__';
|
|
23
|
+
/**
|
|
24
|
+
* Checks `fs:write` on the file an upload will be written to (`file.Provider`, else `options.fs`, else the default
|
|
25
|
+
* upload filesystem, at `file.BaseName`) before the uploader copies it, with that filesystem's mode and domain:
|
|
26
|
+
* enforce refuses with AccessDenied (403) so the formidable temp file is never copied, audit warns, off does
|
|
27
|
+
* nothing. AuthzFsMiddleware checks the copy again, but the uploader turns its denial into an IOFail (500); this
|
|
28
|
+
* gives the 403. Apps add it after middlewares that rename the file.
|
|
29
|
+
*/
|
|
30
|
+
let AuthzUploadMiddleware = class AuthzUploadMiddleware extends http_1.FileUploadMiddleware {
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
super();
|
|
33
|
+
this.options = options;
|
|
34
|
+
}
|
|
35
|
+
async beforeUpload(file, options) {
|
|
36
|
+
// ImmediateFileUploader copies to file.Provider, which an earlier middleware may have replaced; FromFile also
|
|
37
|
+
// falls back on an empty options.fs.
|
|
38
|
+
const named = file.Provider?.Name;
|
|
39
|
+
const fsName = typeof named === 'string' && named !== '' ? named : options?.fs || exports.DEFAULT_UPLOAD_FS;
|
|
40
|
+
const container = this.options.container ?? di_1.DI.RootContainer;
|
|
41
|
+
const config = (0, index_js_1.fsAccessConfig)(fsName, container);
|
|
42
|
+
if (config.mode === 'off')
|
|
43
|
+
return file;
|
|
44
|
+
const provider = (0, fs_1.publishedFs)(fsName, container) ?? (file.Provider?.Name === fsName ? file.Provider : undefined);
|
|
45
|
+
const path = (0, index_js_2.normalizeFsPath)(file.BaseName, provider?.BasePath);
|
|
46
|
+
if (path === '')
|
|
47
|
+
throw new exceptions_1.InvalidArgument(`upload ${JSON.stringify(file.Name)} has no file name to write to`, 'BaseName');
|
|
48
|
+
const service = await (this.options.service ?? ((domain) => (0, decide_js_1.domainService)(container, domain)))(config.domain);
|
|
49
|
+
await (0, decide_js_1.decideFs)({
|
|
50
|
+
fsName,
|
|
51
|
+
mode: config.mode,
|
|
52
|
+
service,
|
|
53
|
+
log: this.options.log ?? (0, authz_1.engineLog)('authz-fs'),
|
|
54
|
+
principal: (this.options.principal ?? authz_1.currentPrincipal)(),
|
|
55
|
+
permission: 'fs:write',
|
|
56
|
+
ref: (0, decide_js_1.refOf)(fsName, path, 'file'),
|
|
57
|
+
subject: (0, index_js_2.fsRowOf)(fsName, path, 'file'),
|
|
58
|
+
});
|
|
59
|
+
return file;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.AuthzUploadMiddleware = AuthzUploadMiddleware;
|
|
63
|
+
exports.AuthzUploadMiddleware = AuthzUploadMiddleware = __decorate([
|
|
64
|
+
(0, di_1.Injectable)(http_1.FileUploadMiddleware),
|
|
65
|
+
__metadata("design:paramtypes", [Object])
|
|
66
|
+
], AuthzUploadMiddleware);
|
|
67
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/http/upload.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAA6D;AAE7D,oCAA6C;AAE7C,oDAAsD;AACtD,oCAA0C;AAC1C,wCAAqD;AAGrD,wDAA2D;AAC3D,uDAAyE;AAEzE,+CAA4D;AAE5D,sEAAsE;AACzD,QAAA,iBAAiB,GAAG,kCAAkC,CAAC;AAYpE;;;;;;GAMG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,2B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AAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtH,MAAM,IAAA,oBAAQ,EAAC;YACb,MAAM;YACN,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO;YACP,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,IAAA,iBAAS,EAAC,UAAU,CAAC;YAC9C,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,wBAAgB,CAAC,EAAE;YACzD,UAAU,EAAE,UAAU;YACtB,GAAG,EAAE,IAAA,iBAAK,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;YAChC,OAAO,EAAE,IAAA,kBAAO,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;SACvC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;;gCA/BY,qBAAqB;IADjC,IAAA,eAAU,EAAC,2BAAoB,CAAC;;GACpB,qBAAqB,CA+BjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './refs/index.js';
|
|
2
|
+
export * from './permissions/index.js';
|
|
3
|
+
export * from './access-config/index.js';
|
|
4
|
+
export * from './acl/index.js';
|
|
5
|
+
export * from './adapter/index.js';
|
|
6
|
+
export * from './middleware/index.js';
|
|
7
|
+
export * from './migrations/index.js';
|
|
8
|
+
export * from './http/index.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,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./refs/index.js"), exports);
|
|
18
|
+
__exportStar(require("./permissions/index.js"), exports);
|
|
19
|
+
__exportStar(require("./access-config/index.js"), exports);
|
|
20
|
+
__exportStar(require("./acl/index.js"), exports);
|
|
21
|
+
__exportStar(require("./adapter/index.js"), exports);
|
|
22
|
+
__exportStar(require("./middleware/index.js"), exports);
|
|
23
|
+
__exportStar(require("./migrations/index.js"), exports);
|
|
24
|
+
__exportStar(require("./http/index.js"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,yDAAuC;AACvC,2DAAyC;AACzC,iDAA+B;AAC/B,qDAAmC;AACnC,wDAAsC;AACtC,wDAAsC;AACtC,kDAAgC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AuthzLog, CheckInput, Decision, Permission, Principal, ResourceRef } from '@spinajs/authz';
|
|
2
|
+
import type { IContainer } from '@spinajs/di';
|
|
3
|
+
import type { FsAccessMode } from '../access-config/index.js';
|
|
4
|
+
import type { FsPathKind, FsRow } from '../refs/index.js';
|
|
5
|
+
/** The part of AuthzService the fs checks call. */
|
|
6
|
+
export interface FsDecideService {
|
|
7
|
+
check(req: CheckInput): Promise<Decision>;
|
|
8
|
+
assert(principal: Principal, permission: Permission, resource?: ResourceRef | object, subject?: unknown): Promise<Decision>;
|
|
9
|
+
}
|
|
10
|
+
/** `error` is for a file ACL update that failed after the IO; default `warn`. */
|
|
11
|
+
export type FsLog = Pick<AuthzLog, 'warn'> & Partial<Pick<AuthzLog, 'error'>>;
|
|
12
|
+
/** One check of one path: enforce asserts, audit checks and warns. */
|
|
13
|
+
export interface FsCheck {
|
|
14
|
+
readonly fsName: string;
|
|
15
|
+
readonly mode: Exclude<FsAccessMode, 'off'>;
|
|
16
|
+
readonly service: FsDecideService;
|
|
17
|
+
readonly log: FsLog;
|
|
18
|
+
readonly principal: Principal;
|
|
19
|
+
readonly permission: Permission;
|
|
20
|
+
readonly ref: ResourceRef;
|
|
21
|
+
readonly subject: FsRow;
|
|
22
|
+
}
|
|
23
|
+
export declare function decideFs({ fsName, mode, service, log, principal, permission, ref, subject }: FsCheck): Promise<Decision>;
|
|
24
|
+
export declare function warnDenied(fsName: string, log: FsLog, principal: Principal, permission: Permission, ref: ResourceRef, decision: Decision): void;
|
|
25
|
+
/** 'root' is the root AuthzService; any other domain must exist already (`authz.domains`): it is never created here. */
|
|
26
|
+
export declare function domainService(container: IContainer, domain: string): Promise<FsDecideService>;
|
|
27
|
+
/** `now` when it is a valid Date, else the system time. */
|
|
28
|
+
export declare const validNow: (now: unknown) => Date;
|
|
29
|
+
/** The AuthzClock the domain's service booted with, else the system time. */
|
|
30
|
+
export declare function domainNow(container: IContainer, domain: string): Promise<Date>;
|
|
31
|
+
export declare const refOf: (fsName: string, normalised: string, kind: FsPathK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ChC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;CACzB;AAED,wBAAsB,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAS9H;AAMD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAG/I;AAED,wHAAwH;AACxH,wBAAsB,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAGnG;AAED,2DAA2D;AAC3D,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,IAAgF,CAAC;AAEzH,6EAA6E;AAC7E,wBAAsB,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpF;AAED,eAAO,MAAM,KAAK,WAAY,MAAM,cAAc,MAAM,QAAQ,UAAU,KAAG,WAA+G,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refOf = exports.validNow = void 0;
|
|
4
|
+
exports.decideFs = decideFs;
|
|
5
|
+
exports.warnDenied = warnDenied;
|
|
6
|
+
exports.domainService = domainService;
|
|
7
|
+
exports.domainNow = domainNow;
|
|
8
|
+
const authz_1 = require("@spinajs/authz");
|
|
9
|
+
async function decideFs({ fsName, mode, service, log, principal, permission, ref, subject }) {
|
|
10
|
+
if (mode === 'enforce') {
|
|
11
|
+
const decision = await service.assert(principal, permission, ref, subject);
|
|
12
|
+
if (!(0, authz_1.definite)(decision))
|
|
13
|
+
throw new authz_1.AccessDenied(conditional(decision));
|
|
14
|
+
return decision;
|
|
15
|
+
}
|
|
16
|
+
const decision = await service.check({ principal, permission, resource: ref, subject });
|
|
17
|
+
if (!(0, authz_1.definite)(decision))
|
|
18
|
+
warnDenied(fsName, log, principal, permission, ref, decision);
|
|
19
|
+
return decision;
|
|
20
|
+
}
|
|
21
|
+
function conditional(decision) {
|
|
22
|
+
return { ...decision, allowed: false, residual: authz_1.FALSE, reason: { code: 'needs_subject', priority: authz_1.DEFAULT_DENY_PRIORITY.needs_subject } };
|
|
23
|
+
}
|
|
24
|
+
function warnDenied(fsName, log, principal, permission, ref, decision) {
|
|
25
|
+
const why = decision.allowed ? 'conditional' : decision.reason?.code;
|
|
26
|
+
log.warn({ fsName, principal: (0, authz_1.principalKey)(principal), permission, resource: (0, authz_1.resourceKey)(ref), why }, 'authz.fs.${fsName}: ${principal} lacks ${permission} on ${resource}${?why} (${why})${/why}; allowed in audit mode');
|
|
27
|
+
}
|
|
28
|
+
/** 'root' is the root AuthzService; any other domain must exist already (`authz.domains`): it is never created here. */
|
|
29
|
+
async function domainService(container, domain) {
|
|
30
|
+
if (domain === 'root')
|
|
31
|
+
return (await container.resolve(authz_1.AuthzService));
|
|
32
|
+
return (await container.resolve(authz_1.AuthzDomains)).service(domain);
|
|
33
|
+
}
|
|
34
|
+
/** `now` when it is a valid Date, else the system time. */
|
|
35
|
+
const validNow = (now) => (now instanceof Date && !Number.isNaN(now.getTime()) ? now : new Date());
|
|
36
|
+
exports.validNow = validNow;
|
|
37
|
+
/** The AuthzClock the domain's service booted with, else the system time. */
|
|
38
|
+
async function domainNow(container, domain) {
|
|
39
|
+
try {
|
|
40
|
+
const domains = await container.resolve(authz_1.AuthzDomains);
|
|
41
|
+
if (domains instanceof authz_1.DefaultAuthzDomains)
|
|
42
|
+
return (0, exports.validNow)(domains.clock(domain).now());
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// no authz host, no such domain or its service has not booted: the system time
|
|
46
|
+
}
|
|
47
|
+
return new Date();
|
|
48
|
+
}
|
|
49
|
+
const refOf = (fsName, normalised, kind) => (normalised === '' ? { type: 'fs', id: fsName } : { type: kind, id: `${fsName}:${normalised}` });
|
|
50
|
+
exports.refOf = refOf;
|
|
51
|
+
//# sourceMappingURL=decide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decide.js","sourceRoot":"","sources":["../../../src/middleware/decide.ts"],"names":[],"mappings":";;;;;;;AAAA,0CAAkK;AA8B3J,KAAK,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAW;IACzG,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC;YAAE,MAAM,IAAI,oBAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;QACvE,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,IAAI,CAAC,IAAA,gBAAQ,EAAC,QAAQ,CAAC;QAAE,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACvF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,WAAW,CAAC,QAAkB;IACrC,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EA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AC;QACtD,IAAI,OAAO,YAAY,2BAAmB;YAAE,OAAO,IAAA,QAAA,QAAQ,EAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACP,+EAA+E;IACjF,CAAC;IACD,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC;AAEM,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAgB,EAAe,EAAE,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,UAAU,EAAE,EAAE,CAAC,CAAC;AAAhL,QAAA,KAAK,GAAL,KAAK,CAA2K"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Principal } from '@spinajs/authz';
|
|
2
|
+
import type { IContainer } from '@spinajs/di';
|
|
3
|
+
import { FsMiddleware } from '@spinajs/fs';
|
|
4
|
+
import type { FsActionContext, fs } from '@spinajs/fs';
|
|
5
|
+
import type { FsAccessConfig } from '../access-config/index.js';
|
|
6
|
+
import type { FileAclStore } from '../acl/store.js';
|
|
7
|
+
import type { FsDecideService, FsLog } from './decide.js';
|
|
8
|
+
export type { FsDecideService, FsLog } from './decide.js';
|
|
9
|
+
export { FS_NO_OWNER_TYPES } from './owner.js';
|
|
10
|
+
export { DEFAULT_SIGNED_URL_TTL_SECONDS } from './signed-url.js';
|
|
11
|
+
export interface AuthzFsMiddlewareOptions {
|
|
12
|
+
/** Where the Configuration, AuthzService, AuthzDomains and the FileAclStore are resolved; default the root. */
|
|
13
|
+
readonly container?: IContainer;
|
|
14
|
+
/** The service that decides for a domain; default the root AuthzService, else `AuthzDomains.service(domain)`. */
|
|
15
|
+
readonly service?: (domain: string) => Promise<FsDecideService>;
|
|
16
|
+
/** Default: the ALS principal, else UNATTENDED (what AuthzService.current() returns). */
|
|
17
|
+
readonly principal?: () => Principal;
|
|
18
|
+
readonly log?: FsLog;
|
|
19
|
+
/** The time signed URL lifetimes count from; default the AuthzClock of the filesystem's domain. */
|
|
20
|
+
readonly now?: () => Date;
|
|
21
|
+
readonly store?: () => Promise<FileAclStore>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Checks every target of every fs action with the `authz.fs.<name>` entry of the target's own filesystem (fs
|
|
25
|
+
* middleware design §2.1) and keeps the file ACL in step with what the action did.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AuthzFsMiddleware extends FsMiddleware {
|
|
28
|
+
protected readonly options: AuthzFsMiddlewareOptions;
|
|
29
|
+
order: number;
|
|
30
|
+
private logger?;
|
|
31
|
+
constructor(options?: AuthzFsMiddlewareOptions);
|
|
32
|
+
isEnabled(target: fs): boolean;
|
|
33
|
+
before(ctx: FsActionContext): Promise<void>;
|
|
34
|
+
after(ctx: FsActionContext, result: unknown): Promise<unknown>;
|
|
35
|
+
protected get container(): IContainer;
|
|
36
|
+
protected configOf(target: fs): FsAccessConfig;
|
|
37
|
+
private get log();
|
|
38
|
+
private service;
|
|
39
|
+
private store;
|
|
40
|
+
private decide;
|
|
41
|
+
private narrowSignedUrl;
|
|
42
|
+
private probeDeleted;
|
|
43
|
+
private applyRows;
|
|
44
|
+
/**
|
|
45
|
+
* A destination that existed keeps its rows (first writer) and the source rows go; otherwise the source rows move
|
|
46
|
+
* there, onto another filesystem too (one table): a directory's whole tree, anything else only its own rows. No
|
|
47
|
+
* owner is stamped: the rows travel with the file. A key whose prefix holds keys leaves its rows to the prefix. A
|
|
48
|
+
* destination too long for a row gets none: the source rows go, its parents' rows cover it.
|
|
49
|
+
*/
|
|
50
|
+
private moveRows;
|
|
51
|
+
private listEach;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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