chyz 1.0.13-rc.14 → 1.0.13-rc.19
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/Doc/Moel kullanma.md +13 -0
- package/Examples/Controllers/ApiController.ts +14 -17
- package/Examples/Controllers/SiteController.ts +2 -9
- 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 +3521 -0
- package/Examples/log/errors.log +373 -0
- package/README.md +265 -12
- package/base/ActionFilter.ts +1 -1
- package/base/Model.ts +3 -0
- package/base/RestClient.ts +4 -4
- package/base/ValidationHttpException.ts +1 -1
- package/dist/base/ActionFilter.js +1 -1
- package/dist/base/ActionFilter.js.map +1 -1
- package/dist/base/Model.js.map +1 -1
- package/dist/base/RestClient.js +4 -4
- package/dist/base/RestClient.js.map +1 -1
- package/dist/base/ValidationHttpException.js +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/package.json +1 -2
- package/dist/rbac/AuthManager.js +13 -5
- 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/package-lock.json +5259 -0
- package/package.json +1 -2
- package/rbac/AuthManager.ts +19 -11
- package/web/WebUser.ts +88 -1
- package/Examples/yarn.lock +0 -2549
|
@@ -19,6 +19,7 @@ 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";
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
@controller("/api")
|
|
@@ -35,22 +36,18 @@ class ApiController extends Controller {
|
|
|
35
36
|
"class": JwtHttpBearerAuth,
|
|
36
37
|
// "auth": this.myCheck
|
|
37
38
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// 'roles': ['@'],
|
|
51
|
-
// }
|
|
52
|
-
// ]
|
|
53
|
-
// }
|
|
39
|
+
'access': {
|
|
40
|
+
'class': AccessControl,
|
|
41
|
+
'only': ['order/list' ],
|
|
42
|
+
'rules': [
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
'allow': true,
|
|
46
|
+
'actions': ['order/list' ],
|
|
47
|
+
'roles': ['edis-manager'],
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
54
51
|
}]
|
|
55
52
|
}
|
|
56
53
|
|
|
@@ -114,7 +111,7 @@ class ApiController extends Controller {
|
|
|
114
111
|
@get("order/list")
|
|
115
112
|
async listOrder(req: Request, res: Response) {
|
|
116
113
|
const {Products}: { Products: ProductsClass } = ModelManager;
|
|
117
|
-
let product = await Products.findAll(
|
|
114
|
+
let product = await Products.findAll( );
|
|
118
115
|
return res.json(product)
|
|
119
116
|
|
|
120
117
|
}
|
|
@@ -102,15 +102,8 @@ class SiteController extends Controller {
|
|
|
102
102
|
"admin"
|
|
103
103
|
],
|
|
104
104
|
permissions: [
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
"hubboxkoli",
|
|
108
|
-
"edisboxold",
|
|
109
|
-
"edisboxnew",
|
|
110
|
-
"hubboxold",
|
|
111
|
-
"hubboxnew",
|
|
112
|
-
"alprboxold",
|
|
113
|
-
"alprboxnew"
|
|
105
|
+
"xxxx",
|
|
106
|
+
|
|
114
107
|
],
|
|
115
108
|
}, user.authkey, null);
|
|
116
109
|
|
|
@@ -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,
|