chyz 1.0.13-rc.11 → 1.0.13-rc.16
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/Examples/Controllers/ApiController.ts +15 -17
- package/Examples/Models/AuthAssignment.ts +50 -0
- package/Examples/Models/AuthItem.ts +59 -0
- package/Examples/Models/AuthItemChild.ts +49 -0
- package/Examples/index.ts +5 -0
- package/Examples/log/app.log +2965 -0
- package/Examples/log/errors.log +290 -0
- package/base/ActionFilter.ts +1 -1
- package/base/BaseError.ts +3 -1
- package/base/Model.ts +7 -2
- package/dist/base/ActionFilter.js +1 -1
- package/dist/base/ActionFilter.js.map +1 -1
- package/dist/base/BaseError.js +5 -1
- package/dist/base/BaseError.js.map +1 -1
- package/dist/base/Model.js +5 -2
- package/dist/base/Model.js.map +1 -1
- package/dist/filters/AccessControl.js +15 -3
- package/dist/filters/AccessControl.js.map +1 -1
- package/dist/filters/AccessRule.js +99 -38
- package/dist/filters/AccessRule.js.map +1 -1
- package/dist/filters/auth/index.js +1 -0
- package/dist/filters/auth/index.js.map +1 -1
- package/dist/package.json +1 -2
- package/dist/rbac/AuthManager.js +11 -3
- package/dist/rbac/AuthManager.js.map +1 -1
- package/dist/web/WebUser.js +78 -0
- package/dist/web/WebUser.js.map +1 -1
- package/filters/AccessControl.ts +19 -6
- package/filters/AccessRule.ts +61 -16
- package/filters/auth/index.ts +1 -0
- package/package-lock.json +5259 -0
- package/package.json +1 -2
- package/rbac/AuthManager.ts +17 -9
- package/web/WebUser.ts +88 -1
- package/Examples/yarn.lock +0 -2549
|
@@ -19,6 +19,8 @@ import {JwtHttpBearerAuth} from "../../filters/auth";
|
|
|
19
19
|
import {ValidationHttpException} from "../../base";
|
|
20
20
|
import {ForbiddenHttpException} from "../../base";
|
|
21
21
|
import {ProductsClass} from "../Models/Products";
|
|
22
|
+
import {AccessControl} from "../../filters";
|
|
23
|
+
import {AuthManager} from "../../rbac/AuthManager";
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
@controller("/api")
|
|
@@ -35,22 +37,18 @@ class ApiController extends Controller {
|
|
|
35
37
|
"class": JwtHttpBearerAuth,
|
|
36
38
|
// "auth": this.myCheck
|
|
37
39
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// 'roles': ['@'],
|
|
51
|
-
// }
|
|
52
|
-
// ]
|
|
53
|
-
// }
|
|
40
|
+
'access': {
|
|
41
|
+
'class': AccessControl,
|
|
42
|
+
'only': ['order/list' ],
|
|
43
|
+
'rules': [
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
'allow': true,
|
|
47
|
+
'actions': ['order/list' ],
|
|
48
|
+
'roles': ['admin2'],
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
54
52
|
}]
|
|
55
53
|
}
|
|
56
54
|
|
|
@@ -114,7 +112,7 @@ class ApiController extends Controller {
|
|
|
114
112
|
@get("order/list")
|
|
115
113
|
async listOrder(req: Request, res: Response) {
|
|
116
114
|
const {Products}: { Products: ProductsClass } = ModelManager;
|
|
117
|
-
let product = await Products.findAll(
|
|
115
|
+
let product = await Products.findAll( );
|
|
118
116
|
return res.json(product)
|
|
119
117
|
|
|
120
118
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {DataTypes, Model, ModelManager, Relation} from "../../base";
|
|
9
|
+
|
|
10
|
+
export class AuthAssignmentClass extends Model {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
|
|
13
|
+
tableName() {
|
|
14
|
+
return 'auth_assignment';
|
|
15
|
+
}
|
|
16
|
+
attributes() {
|
|
17
|
+
return {
|
|
18
|
+
|
|
19
|
+
// Model attributes are defined here
|
|
20
|
+
item_name: {
|
|
21
|
+
type: DataTypes.STRING,
|
|
22
|
+
primaryKey:true,
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
user_id : {
|
|
26
|
+
type: DataTypes.STRING,
|
|
27
|
+
allowNull: false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init(){
|
|
34
|
+
super.init();
|
|
35
|
+
this.model().removeAttribute('id')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
relations(): Relation[] {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
type: "hasMany",
|
|
42
|
+
foreignKey: "name",
|
|
43
|
+
sourceKey:'item_name',
|
|
44
|
+
model: ModelManager.AuthItem.model()
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import {DataTypes, Model, ModelManager, Relation} from "../../base";
|
|
11
|
+
|
|
12
|
+
export class AuthItemClass extends Model {
|
|
13
|
+
[x: string]: any;
|
|
14
|
+
|
|
15
|
+
tableName() {
|
|
16
|
+
return 'auth_item';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
attributes() {
|
|
20
|
+
return {
|
|
21
|
+
// Model attributes are defined here
|
|
22
|
+
name: {
|
|
23
|
+
type: DataTypes.STRING,
|
|
24
|
+
primaryKey:true,
|
|
25
|
+
allowNull: false
|
|
26
|
+
},
|
|
27
|
+
type: {
|
|
28
|
+
type: DataTypes.INTEGER,
|
|
29
|
+
allowNull: false
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
type: DataTypes.STRING,
|
|
33
|
+
allowNull: false
|
|
34
|
+
},
|
|
35
|
+
rule_name: {
|
|
36
|
+
type: DataTypes.STRING,
|
|
37
|
+
allowNull: false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
init() {
|
|
44
|
+
super.init();
|
|
45
|
+
this.model().removeAttribute('id')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
relations(): Relation[] {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
type: "hasOne",
|
|
52
|
+
foreignKey: "item_name",
|
|
53
|
+
model: ModelManager.AuthAssignment.model()
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
3
|
+
* Author: Cihan Ozturk
|
|
4
|
+
* E-mail: cihan@chy.com.tr
|
|
5
|
+
* Github:https://github.com/cihan53/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import {DataTypes, Model, ModelManager, Relation} from "../../base";
|
|
10
|
+
|
|
11
|
+
export class AuthItemChildClass extends Model {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
|
|
14
|
+
tableName() {
|
|
15
|
+
return 'auth_item_child';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
attributes() {
|
|
19
|
+
return {
|
|
20
|
+
// Model attributes are defined here
|
|
21
|
+
parent: {
|
|
22
|
+
type: DataTypes.STRING,
|
|
23
|
+
primaryKey: true,
|
|
24
|
+
allowNull: false
|
|
25
|
+
},
|
|
26
|
+
child: {
|
|
27
|
+
type: DataTypes.STRING,
|
|
28
|
+
allowNull: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
init() {
|
|
34
|
+
super.init();
|
|
35
|
+
this.model().removeAttribute('id')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
relations(): Relation[] {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
type: "hasOne",
|
|
42
|
+
foreignKey: "item_name",
|
|
43
|
+
model: ModelManager.AuthAssignment.model()
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
package/Examples/index.ts
CHANGED
|
@@ -7,17 +7,22 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
import {BaseChyz} from "../index";
|
|
10
|
+
|
|
10
11
|
require('dotenv-flow').config();
|
|
11
12
|
import Chyz from "../Chyz";
|
|
12
13
|
import {WebUser} from "../web/WebUser";
|
|
13
14
|
import {User} from "./Models/User";
|
|
14
15
|
import {DbConnection} from "../base";
|
|
16
|
+
import {AuthManager} from "../rbac/AuthManager";
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
let config = {
|
|
18
20
|
port: process.env.PORT,
|
|
19
21
|
controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
|
|
20
22
|
components: {
|
|
23
|
+
authManager: {
|
|
24
|
+
class: AuthManager,
|
|
25
|
+
},
|
|
21
26
|
db: {
|
|
22
27
|
class: DbConnection,
|
|
23
28
|
database: process.env.DBDATABASE,
|