chyz 2.0.0-rc.8 → 2.0.1-rc.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/BaseChyz.d.ts +73 -56
- package/BaseChyz.d.ts.map +1 -1
- package/BaseChyz.js +569 -404
- package/README.md +1 -1
- package/base/ActionFilter.d.ts +32 -32
- package/base/ActionFilter.d.ts.map +1 -1
- package/base/ActionFilter.js +82 -82
- package/base/BadRequestHttpException.d.ts +6 -0
- package/base/BadRequestHttpException.d.ts.map +1 -0
- package/base/BadRequestHttpException.js +17 -0
- package/base/BaseError.d.ts +43 -10
- package/base/BaseError.d.ts.map +1 -1
- package/base/BaseError.js +58 -26
- package/base/Behavior.d.ts +3 -3
- package/base/Behavior.js +7 -7
- package/base/CBaseObject.d.ts +4 -4
- package/base/CBaseObject.d.ts.map +1 -1
- package/base/CBaseObject.js +16 -16
- package/base/CEvents.d.ts +13 -0
- package/base/CEvents.d.ts.map +1 -0
- package/base/CEvents.js +24 -0
- package/base/CRequest.d.ts +1 -1
- package/base/CRequest.js +10 -10
- package/base/CWebController.d.ts +43 -43
- package/base/CWebController.d.ts.map +1 -1
- package/base/CWebController.js +81 -74
- package/base/Component.d.ts +20 -20
- package/base/Component.d.ts.map +1 -1
- package/base/Component.js +57 -57
- package/base/Configurable.d.ts +2 -2
- package/base/Configurable.js +8 -8
- package/base/DataErrorDbException.d.ts +5 -5
- package/base/DataErrorDbException.d.ts.map +1 -1
- package/base/DataErrorDbException.js +17 -17
- package/base/DbConnection.d.ts +12 -12
- package/base/DbConnection.js +53 -53
- package/base/ForbiddenHttpException.d.ts +4 -4
- package/base/ForbiddenHttpException.d.ts.map +1 -1
- package/base/ForbiddenHttpException.js +16 -16
- package/base/InvalidArgumentException.d.ts +5 -5
- package/base/InvalidArgumentException.d.ts.map +1 -1
- package/base/InvalidArgumentException.js +17 -17
- package/base/InvalidConfigException.d.ts +5 -5
- package/base/InvalidConfigException.d.ts.map +1 -1
- package/base/InvalidConfigException.js +17 -17
- package/base/Logs.d.ts +21 -21
- package/base/Logs.d.ts.map +1 -1
- package/base/Logs.js +57 -57
- package/base/Model.d.ts +301 -298
- package/base/Model.d.ts.map +1 -1
- package/base/Model.js +545 -507
- package/base/ModelManager.d.ts +1 -1
- package/base/ModelManager.js +19 -19
- package/base/NotFoundHttpException.d.ts +5 -5
- package/base/NotFoundHttpException.d.ts.map +1 -1
- package/base/NotFoundHttpException.js +17 -17
- package/base/RestClient.d.ts +6 -6
- package/base/RestClient.d.ts.map +1 -1
- package/base/RestClient.js +25 -25
- package/base/UnauthorizedHttpException.d.ts +5 -5
- package/base/UnauthorizedHttpException.d.ts.map +1 -1
- package/base/UnauthorizedHttpException.js +17 -17
- package/base/ValidationHttpException.d.ts +5 -5
- package/base/ValidationHttpException.d.ts.map +1 -1
- package/base/ValidationHttpException.js +17 -17
- package/base/db/Exception.d.ts +6 -6
- package/base/db/Exception.js +15 -15
- package/base/index.d.ts +19 -18
- package/base/index.d.ts.map +1 -1
- package/base/index.js +41 -39
- package/decorator/Middleware.d.ts +3 -3
- package/decorator/Middleware.js +11 -11
- package/decorator/controller.d.ts +2 -2
- package/decorator/controller.js +24 -24
- package/decorator/delete.d.ts +3 -0
- package/decorator/delete.d.ts.map +1 -0
- package/decorator/delete.js +36 -0
- package/decorator/enums/ControllerDecoratorParams.d.ts +5 -5
- package/decorator/enums/ControllerDecoratorParams.js +9 -9
- package/decorator/get.d.ts +2 -2
- package/decorator/get.js +36 -36
- package/decorator/index.d.ts +5 -3
- package/decorator/index.d.ts.map +1 -1
- package/decorator/index.js +13 -9
- package/decorator/post.d.ts +2 -2
- package/decorator/post.js +36 -36
- package/decorator/put.d.ts +3 -0
- package/decorator/put.d.ts.map +1 -0
- package/decorator/put.js +36 -0
- package/filters/AccessControl.d.ts +12 -12
- package/filters/AccessControl.d.ts.map +1 -1
- package/filters/AccessControl.js +83 -83
- package/filters/AccessRule.d.ts +82 -82
- package/filters/AccessRule.d.ts.map +1 -1
- package/filters/AccessRule.js +136 -137
- package/filters/auth/AuthInterface.d.ts +25 -25
- package/filters/auth/AuthInterface.js +2 -2
- package/filters/auth/AuthMethod.d.ts +37 -37
- package/filters/auth/AuthMethod.d.ts.map +1 -1
- package/filters/auth/AuthMethod.js +82 -82
- package/filters/auth/HttpBasicAuth.d.ts +23 -22
- package/filters/auth/HttpBasicAuth.d.ts.map +1 -1
- package/filters/auth/HttpBasicAuth.js +78 -72
- package/filters/auth/HttpBearerAuth.d.ts +17 -17
- package/filters/auth/HttpBearerAuth.d.ts.map +1 -1
- package/filters/auth/HttpBearerAuth.js +33 -32
- package/filters/auth/HttpHeaderAuth.d.ts +18 -14
- package/filters/auth/HttpHeaderAuth.d.ts.map +1 -1
- package/filters/auth/HttpHeaderAuth.js +64 -57
- package/filters/auth/JwtHttpBearerAuth.d.ts +20 -20
- package/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -1
- package/filters/auth/JwtHttpBearerAuth.js +87 -81
- package/filters/auth/KeyCloakHttpBearerAuth.d.ts +22 -22
- package/filters/auth/KeyCloakHttpBearerAuth.js +116 -116
- package/filters/auth/index.d.ts +4 -4
- package/filters/auth/index.js +11 -11
- package/filters/index.d.ts +2 -2
- package/filters/index.js +7 -7
- package/index.d.ts +28 -21
- package/index.d.ts.map +1 -1
- package/index.js +71 -60
- package/model/RouteDefinition.d.ts +6 -6
- package/model/RouteDefinition.js +8 -8
- package/package.json +22 -24
- package/rbac/AuthAssignment.d.ts +18 -18
- package/rbac/AuthAssignment.js +44 -44
- package/rbac/AuthItem.d.ts +26 -26
- package/rbac/AuthItem.js +51 -51
- package/rbac/AuthItemChild.d.ts +18 -18
- package/rbac/AuthItemChild.js +43 -43
- package/rbac/AuthManager.d.ts +111 -111
- package/rbac/AuthManager.d.ts.map +1 -1
- package/rbac/AuthManager.js +356 -355
- package/rbac/index.d.ts +5 -0
- package/rbac/index.d.ts.map +1 -0
- package/rbac/index.js +28 -0
- package/requiments/Glob.d.ts +2 -2
- package/requiments/Glob.js +10 -10
- package/requiments/ReflectUtil.js +24 -24
- package/requiments/Utils.d.ts +1 -8
- package/requiments/Utils.d.ts.map +1 -1
- package/requiments/Utils.js +115 -112
- package/validators/BooleanValidator.js +1 -1
- package/validators/CompareValidator.js +1 -1
- package/validators/DateValidator.js +1 -1
- package/validators/EmailValidator.js +1 -1
- package/validators/Validator.d.ts +17 -17
- package/validators/Validator.js +27 -27
- package/web/IdentityInterface.d.ts +55 -54
- package/web/IdentityInterface.d.ts.map +1 -1
- package/web/IdentityInterface.js +8 -8
- package/web/WebUser.d.ts +71 -71
- package/web/WebUser.js +165 -165
package/decorator/get.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
export declare const get: (path: string) => MethodDecorator;
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const get: (path: string) => MethodDecorator;
|
|
3
3
|
//# sourceMappingURL=get.d.ts.map
|
package/decorator/get.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.get = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
-
* Author: Cihan Ozturk
|
|
7
|
-
* E-mail: cihan@chy.com.tr
|
|
8
|
-
* Github:https://github.com/cihan53/
|
|
9
|
-
*/
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
require("reflect-metadata");
|
|
12
|
-
const get = (path) => {
|
|
13
|
-
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
return (target, propertyKey) => {
|
|
16
|
-
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
-
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
-
}
|
|
23
|
-
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
-
routes.push({
|
|
27
|
-
id: "",
|
|
28
|
-
requestMethod: 'get',
|
|
29
|
-
path,
|
|
30
|
-
methodName: propertyKey
|
|
31
|
-
});
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.get = get;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
+
* Author: Cihan Ozturk
|
|
7
|
+
* E-mail: cihan@chy.com.tr
|
|
8
|
+
* Github:https://github.com/cihan53/
|
|
9
|
+
*/
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const get = (path) => {
|
|
13
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return (target, propertyKey) => {
|
|
16
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
+
}
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
+
routes.push({
|
|
27
|
+
id: "",
|
|
28
|
+
requestMethod: 'get',
|
|
29
|
+
path,
|
|
30
|
+
methodName: propertyKey
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.get = get;
|
package/decorator/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { controller } from "./controller";
|
|
2
|
-
export { get } from "./get";
|
|
3
|
-
export { post } from "./post";
|
|
1
|
+
export { controller } from "./controller";
|
|
2
|
+
export { get } from "./get";
|
|
3
|
+
export { post } from "./post";
|
|
4
|
+
export { put } from "./put";
|
|
5
|
+
export { del } from "./delete";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/decorator/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA"}
|
package/decorator/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.post = exports.get = exports.controller = void 0;
|
|
4
|
-
var controller_1 = require("./controller");
|
|
5
|
-
Object.defineProperty(exports, "controller", { enumerable: true, get: function () { return controller_1.controller; } });
|
|
6
|
-
var get_1 = require("./get");
|
|
7
|
-
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
|
|
8
|
-
var post_1 = require("./post");
|
|
9
|
-
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return post_1.post; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.del = exports.put = exports.post = exports.get = exports.controller = void 0;
|
|
4
|
+
var controller_1 = require("./controller");
|
|
5
|
+
Object.defineProperty(exports, "controller", { enumerable: true, get: function () { return controller_1.controller; } });
|
|
6
|
+
var get_1 = require("./get");
|
|
7
|
+
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
|
|
8
|
+
var post_1 = require("./post");
|
|
9
|
+
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return post_1.post; } });
|
|
10
|
+
var put_1 = require("./put");
|
|
11
|
+
Object.defineProperty(exports, "put", { enumerable: true, get: function () { return put_1.put; } });
|
|
12
|
+
var delete_1 = require("./delete");
|
|
13
|
+
Object.defineProperty(exports, "del", { enumerable: true, get: function () { return delete_1.del; } });
|
package/decorator/post.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
export declare const post: (path: string) => MethodDecorator;
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const post: (path: string) => MethodDecorator;
|
|
3
3
|
//# sourceMappingURL=post.d.ts.map
|
package/decorator/post.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.post = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
-
* Author: Cihan Ozturk
|
|
7
|
-
* E-mail: cihan@chy.com.tr
|
|
8
|
-
* Github:https://github.com/cihan53/
|
|
9
|
-
*/
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
require("reflect-metadata");
|
|
12
|
-
const post = (path) => {
|
|
13
|
-
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
return (target, propertyKey) => {
|
|
16
|
-
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
-
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
-
}
|
|
23
|
-
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
-
routes.push({
|
|
27
|
-
id: "",
|
|
28
|
-
requestMethod: 'post',
|
|
29
|
-
path,
|
|
30
|
-
methodName: propertyKey
|
|
31
|
-
});
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.post = post;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.post = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
+
* Author: Cihan Ozturk
|
|
7
|
+
* E-mail: cihan@chy.com.tr
|
|
8
|
+
* Github:https://github.com/cihan53/
|
|
9
|
+
*/
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const post = (path) => {
|
|
13
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return (target, propertyKey) => {
|
|
16
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
+
}
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
+
routes.push({
|
|
27
|
+
id: "",
|
|
28
|
+
requestMethod: 'post',
|
|
29
|
+
path,
|
|
30
|
+
methodName: propertyKey
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.post = post;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../src/decorator/put.ts"],"names":[],"mappings":"AAOA,OAAQ,kBAAkB,CAAC;AAG3B,eAAO,MAAM,GAAG,SAAU,MAAM,KAAG,eAyBlC,CAAC"}
|
package/decorator/put.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.put = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
+
* Author: Cihan Ozturk
|
|
7
|
+
* E-mail: cihan@chy.com.tr
|
|
8
|
+
* Github:https://github.com/cihan53/
|
|
9
|
+
*/
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const put = (path) => {
|
|
13
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return (target, propertyKey) => {
|
|
16
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
+
}
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
+
routes.push({
|
|
27
|
+
id: "",
|
|
28
|
+
requestMethod: 'put',
|
|
29
|
+
path,
|
|
30
|
+
methodName: propertyKey
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.put = put;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
|
-
import { Request, Response } from "../index";
|
|
3
|
-
import { ActionFilter } from "../base
|
|
4
|
-
import { WebUser } from "../web/WebUser";
|
|
5
|
-
export declare class AccessControl extends ActionFilter {
|
|
6
|
-
user: any;
|
|
7
|
-
rules: any;
|
|
8
|
-
denyCallback: any;
|
|
9
|
-
init(): void;
|
|
10
|
-
beforeAction(action: any, request: Request, res: Response): Promise<boolean>;
|
|
11
|
-
denyAccess(user: WebUser): void;
|
|
12
|
-
}
|
|
1
|
+
/// <reference types="express" />
|
|
2
|
+
import { Request, Response } from "../index";
|
|
3
|
+
import { ActionFilter } from "../base";
|
|
4
|
+
import { WebUser } from "../web/WebUser";
|
|
5
|
+
export declare class AccessControl extends ActionFilter {
|
|
6
|
+
user: any;
|
|
7
|
+
rules: any;
|
|
8
|
+
denyCallback: any;
|
|
9
|
+
init(): void;
|
|
10
|
+
beforeAction(action: any, request: Request, res: Response): Promise<boolean>;
|
|
11
|
+
denyAccess(user: WebUser): void;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=AccessControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessControl.d.ts","sourceRoot":"","sources":["../../src/filters/AccessControl.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAU,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AccessControl.d.ts","sourceRoot":"","sources":["../../src/filters/AccessControl.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAU,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAIvC,qBAAa,aAAc,SAAQ,YAAY;IAEpC,IAAI,EAAE,GAAG,CAAQ;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,YAAY,EAAE,GAAG,CAAQ;IAEzB,IAAI;IAgBE,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAC,GAAG,EAAC,QAAQ;IAiC7D,UAAU,CAAC,IAAI,EAAE,OAAO;CAMlC"}
|
package/filters/AccessControl.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AccessControl = void 0;
|
|
13
|
-
/*
|
|
14
|
-
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
15
|
-
* Author: Cihan Ozturk
|
|
16
|
-
* E-mail: cihan@chy.com.tr
|
|
17
|
-
* Github:https://github.com/cihan53/
|
|
18
|
-
*/
|
|
19
|
-
const index_1 = require("../index");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const AccessRule_1 = require("./AccessRule");
|
|
23
|
-
const WebUser_1 = require("../web/WebUser");
|
|
24
|
-
const Utils_1 = require("../requiments/Utils");
|
|
25
|
-
class AccessControl extends
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
this.user = null;
|
|
29
|
-
this.denyCallback = null;
|
|
30
|
-
}
|
|
31
|
-
init() {
|
|
32
|
-
var _a;
|
|
33
|
-
super.init();
|
|
34
|
-
if (this.user == undefined) {
|
|
35
|
-
this.user = (_a = Utils_1.Utils.cloneDeep(index_1.BaseChyz.getComponent("user"))) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser();
|
|
36
|
-
}
|
|
37
|
-
this.rules.forEach((rule, index) => {
|
|
38
|
-
if (rule === Object(rule)) {
|
|
39
|
-
this.rules[index] = Utils_1.Utils.createObject(new AccessRule_1.AccessRule(), rule);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
beforeAction(action, request, res) {
|
|
44
|
-
var _a, _b;
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
let allow;
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
let user = (_a = request.user) !== null && _a !== void 0 ? _a : this.user;
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
user.identity = (_b = request.identity) !== null && _b !== void 0 ? _b : null;
|
|
51
|
-
for (const rulesKey in this.rules) {
|
|
52
|
-
let rule = this.rules[rulesKey];
|
|
53
|
-
if ((allow = yield rule.allows(action, user, request))) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
else if (allow === false) {
|
|
57
|
-
if (this.denyCallback != null) {
|
|
58
|
-
rule.denyCallback.apply(rule, action);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.denyAccess(user);
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (this.denyCallback != null) {
|
|
67
|
-
this.denyCallback.apply(null, action);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.denyAccess(user);
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
denyAccess(user) {
|
|
76
|
-
if (user != undefined && user.getIsGuest()) {
|
|
77
|
-
user.loginRequired();
|
|
78
|
-
}
|
|
79
|
-
else
|
|
80
|
-
throw new
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.AccessControl = AccessControl;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AccessControl = void 0;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
15
|
+
* Author: Cihan Ozturk
|
|
16
|
+
* E-mail: cihan@chy.com.tr
|
|
17
|
+
* Github:https://github.com/cihan53/
|
|
18
|
+
*/
|
|
19
|
+
const index_1 = require("../index");
|
|
20
|
+
const base_1 = require("../base");
|
|
21
|
+
const base_2 = require("../base");
|
|
22
|
+
const AccessRule_1 = require("./AccessRule");
|
|
23
|
+
const WebUser_1 = require("../web/WebUser");
|
|
24
|
+
const Utils_1 = require("../requiments/Utils");
|
|
25
|
+
class AccessControl extends base_2.ActionFilter {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.user = null;
|
|
29
|
+
this.denyCallback = null;
|
|
30
|
+
}
|
|
31
|
+
init() {
|
|
32
|
+
var _a;
|
|
33
|
+
super.init();
|
|
34
|
+
if (this.user == undefined) {
|
|
35
|
+
this.user = (_a = Utils_1.Utils.cloneDeep(index_1.BaseChyz.getComponent("user"))) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser();
|
|
36
|
+
}
|
|
37
|
+
this.rules.forEach((rule, index) => {
|
|
38
|
+
if (rule === Object(rule)) {
|
|
39
|
+
this.rules[index] = Utils_1.Utils.createObject(new AccessRule_1.AccessRule(), rule);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
beforeAction(action, request, res) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
let allow;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
let user = (_a = request.user) !== null && _a !== void 0 ? _a : this.user;
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
user.identity = (_b = request.identity) !== null && _b !== void 0 ? _b : null;
|
|
51
|
+
for (const rulesKey in this.rules) {
|
|
52
|
+
let rule = this.rules[rulesKey];
|
|
53
|
+
if ((allow = yield rule.allows(action, user, request))) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
else if (allow === false) {
|
|
57
|
+
if (this.denyCallback != null) {
|
|
58
|
+
rule.denyCallback.apply(rule, action);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.denyAccess(user);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (this.denyCallback != null) {
|
|
67
|
+
this.denyCallback.apply(null, action);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.denyAccess(user);
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
denyAccess(user) {
|
|
76
|
+
if (user != undefined && user.getIsGuest()) {
|
|
77
|
+
user.loginRequired();
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
throw new base_1.ForbiddenHttpException(index_1.BaseChyz.t('You are not allowed to perform this action.'));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.AccessControl = AccessControl;
|
package/filters/AccessRule.d.ts
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { WebUser } from "../web/WebUser";
|
|
2
|
-
import { Component } from "../base
|
|
3
|
-
import { Request } from "express";
|
|
4
|
-
export declare class AccessRule extends Component {
|
|
5
|
-
/**
|
|
6
|
-
* @var
|
|
7
|
-
*/
|
|
8
|
-
allow: any;
|
|
9
|
-
/**
|
|
10
|
-
* @var array list of action IDs that this rule applies to. The comparison is case-sensitive.
|
|
11
|
-
* If not set or empty, it means this rule applies to all actions.
|
|
12
|
-
*/
|
|
13
|
-
actions: any;
|
|
14
|
-
/**
|
|
15
|
-
* @var array list of the controller IDs that this rule applies to.
|
|
16
|
-
*/
|
|
17
|
-
controllers: any;
|
|
18
|
-
/**
|
|
19
|
-
* - `?`: matches a guest user (not authenticated yet)
|
|
20
|
-
* - `@`: matches an authenticated user
|
|
21
|
-
*/
|
|
22
|
-
roles: any;
|
|
23
|
-
/**
|
|
24
|
-
* @var array list of RBAC (Role-Based Access Control) permissions that this rules applies to.
|
|
25
|
-
*/
|
|
26
|
-
permissions: any;
|
|
27
|
-
/**
|
|
28
|
-
* @var array|Closure parameters to pass to the [[User::can()]] function for evaluating
|
|
29
|
-
* user permissions in [[$roles]].
|
|
30
|
-
*
|
|
31
|
-
* If this is an array, it will be passed directly to [[User::can()]]. For example for passing an
|
|
32
|
-
* ID from the current request, you may use the following:
|
|
33
|
-
*
|
|
34
|
-
* ```php
|
|
35
|
-
* ['postId' => Yii::$app->request->get('id')]
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* You may also specify a closure that returns an array. This can be used to
|
|
39
|
-
* evaluate the array values only if they are needed, for example when a model needs to be
|
|
40
|
-
* loaded like in the following code:
|
|
41
|
-
*
|
|
42
|
-
* ```php
|
|
43
|
-
* 'rules' => [
|
|
44
|
-
* [
|
|
45
|
-
* 'allow' => true,
|
|
46
|
-
* 'actions' => ['update'],
|
|
47
|
-
* 'roles' => ['updatePost'],
|
|
48
|
-
* 'roleParams' => function($rule) {
|
|
49
|
-
* return ['post' => Post::findOne(Yii::$app->request->get('id'))];
|
|
50
|
-
* },
|
|
51
|
-
* ],
|
|
52
|
-
* ],
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* A reference to the [[AccessRule]] instance will be passed to the closure as the first parameter.
|
|
56
|
-
*
|
|
57
|
-
* @see roles
|
|
58
|
-
* @since 2.0.12
|
|
59
|
-
*/
|
|
60
|
-
roleParams: any;
|
|
61
|
-
/**
|
|
62
|
-
* @var array list of user IP addresses that this rule applies to. An IP address
|
|
63
|
-
* can contain the wildcard `*` at the end so that it matches IP addresses with the same prefix.
|
|
64
|
-
* For example, '192.168.*' matches all IP addresses in the segment '192.168.'.
|
|
65
|
-
* It may also contain a pattern/mask like '172.16.0.0/12' which would match all IPs from the
|
|
66
|
-
* 20-bit private network block in RFC1918.
|
|
67
|
-
* If not set or empty, it means this rule applies to all IP addresses.
|
|
68
|
-
*/
|
|
69
|
-
ips: any;
|
|
70
|
-
allows(action: any, user: WebUser, request: Request): Promise<any>;
|
|
71
|
-
/**
|
|
72
|
-
* @param
|
|
73
|
-
* @return bool whether the rule applies to the action
|
|
74
|
-
*/
|
|
75
|
-
protected matchAction(action: any): any;
|
|
76
|
-
/**
|
|
77
|
-
* @param
|
|
78
|
-
* @return bool whether the rule applies to the controller
|
|
79
|
-
*/
|
|
80
|
-
protected matchController(controller: any): boolean;
|
|
81
|
-
protected matchRole(user: WebUser): Promise<boolean>;
|
|
82
|
-
}
|
|
1
|
+
import { WebUser } from "../web/WebUser";
|
|
2
|
+
import { Component } from "../base";
|
|
3
|
+
import { Request } from "express";
|
|
4
|
+
export declare class AccessRule extends Component {
|
|
5
|
+
/**
|
|
6
|
+
* @var allow whether this is an 'allow' rule or 'deny' rule.
|
|
7
|
+
*/
|
|
8
|
+
allow: any;
|
|
9
|
+
/**
|
|
10
|
+
* @var array list of action IDs that this rule applies to. The comparison is case-sensitive.
|
|
11
|
+
* If not set or empty, it means this rule applies to all actions.
|
|
12
|
+
*/
|
|
13
|
+
actions: any;
|
|
14
|
+
/**
|
|
15
|
+
* @var array list of the controller IDs that this rule applies to.
|
|
16
|
+
*/
|
|
17
|
+
controllers: any;
|
|
18
|
+
/**
|
|
19
|
+
* - `?`: matches a guest user (not authenticated yet)
|
|
20
|
+
* - `@`: matches an authenticated user
|
|
21
|
+
*/
|
|
22
|
+
roles: any;
|
|
23
|
+
/**
|
|
24
|
+
* @var array list of RBAC (Role-Based Access Control) permissions that this rules applies to.
|
|
25
|
+
*/
|
|
26
|
+
permissions: any;
|
|
27
|
+
/**
|
|
28
|
+
* @var array|Closure parameters to pass to the [[User::can()]] function for evaluating
|
|
29
|
+
* user permissions in [[$roles]].
|
|
30
|
+
*
|
|
31
|
+
* If this is an array, it will be passed directly to [[User::can()]]. For example for passing an
|
|
32
|
+
* ID from the current request, you may use the following:
|
|
33
|
+
*
|
|
34
|
+
* ```php
|
|
35
|
+
* ['postId' => Yii::$app->request->get('id')]
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* You may also specify a closure that returns an array. This can be used to
|
|
39
|
+
* evaluate the array values only if they are needed, for example when a model needs to be
|
|
40
|
+
* loaded like in the following code:
|
|
41
|
+
*
|
|
42
|
+
* ```php
|
|
43
|
+
* 'rules' => [
|
|
44
|
+
* [
|
|
45
|
+
* 'allow' => true,
|
|
46
|
+
* 'actions' => ['update'],
|
|
47
|
+
* 'roles' => ['updatePost'],
|
|
48
|
+
* 'roleParams' => function($rule) {
|
|
49
|
+
* return ['post' => Post::findOne(Yii::$app->request->get('id'))];
|
|
50
|
+
* },
|
|
51
|
+
* ],
|
|
52
|
+
* ],
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* A reference to the [[AccessRule]] instance will be passed to the closure as the first parameter.
|
|
56
|
+
*
|
|
57
|
+
* @see roles
|
|
58
|
+
* @since 2.0.12
|
|
59
|
+
*/
|
|
60
|
+
roleParams: any;
|
|
61
|
+
/**
|
|
62
|
+
* @var array list of user IP addresses that this rule applies to. An IP address
|
|
63
|
+
* can contain the wildcard `*` at the end so that it matches IP addresses with the same prefix.
|
|
64
|
+
* For example, '192.168.*' matches all IP addresses in the segment '192.168.'.
|
|
65
|
+
* It may also contain a pattern/mask like '172.16.0.0/12' which would match all IPs from the
|
|
66
|
+
* 20-bit private network block in RFC1918.
|
|
67
|
+
* If not set or empty, it means this rule applies to all IP addresses.
|
|
68
|
+
*/
|
|
69
|
+
ips: any;
|
|
70
|
+
allows(action: any, user: WebUser, request: Request): Promise<any>;
|
|
71
|
+
/**
|
|
72
|
+
* @param action $action the action
|
|
73
|
+
* @return bool whether the rule applies to the action
|
|
74
|
+
*/
|
|
75
|
+
protected matchAction(action: any): any;
|
|
76
|
+
/**
|
|
77
|
+
* @param controller $controller the controller
|
|
78
|
+
* @return bool whether the rule applies to the controller
|
|
79
|
+
*/
|
|
80
|
+
protected matchController(controller: any): boolean;
|
|
81
|
+
protected matchRole(user: WebUser): Promise<boolean>;
|
|
82
|
+
}
|
|
83
83
|
//# sourceMappingURL=AccessRule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../src/filters/AccessRule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../src/filters/AccessRule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAElC,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAIhC,qBAAa,UAAW,SAAQ,SAAS;IAErC;;OAEG;IACI,KAAK,EAAE,GAAG,CAAC;IAClB;;;OAGG;IACI,OAAO,EAAE,GAAG,CAAC;IAEpB;;OAEG;IACI,WAAW,EAAE,GAAG,CAAC;IAExB;;;OAGG;IAEI,KAAK,EAAE,GAAG,CAAC;IAElB;;OAEG;IACI,WAAW,EAAE,GAAG,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACI,UAAU,EAAE,GAAG,CAAM;IAG5B;;;;;;;OAOG;IACI,GAAG,EAAE,GAAG,CAAC;IAGH,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAoBhE;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG;IAIjC;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,GAAG;cAezB,SAAS,CAAC,IAAI,EAAE,OAAO;CA6C1C"}
|