chyz 1.0.13-rc.4 → 1.0.13-rc.5
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.ts +384 -0
- package/Chyz.ts +11 -0
- package/Examples/Controllers/ApiController.ts +140 -0
- package/Examples/Controllers/KeyCloakController.ts +100 -0
- package/Examples/Controllers/PublicController.ts +42 -0
- package/Examples/Controllers/SiteController.ts +139 -0
- package/Examples/Models/Categories.ts +48 -0
- package/Examples/Models/Customer.ts +115 -0
- package/Examples/Models/KeycloakUser.ts +66 -0
- package/Examples/Models/Order.ts +64 -0
- package/Examples/Models/OrderItem.ts +27 -0
- package/Examples/Models/ProductModels.ts +49 -0
- package/Examples/Models/ProductToCategories.ts +46 -0
- package/Examples/Models/Products.ts +50 -0
- package/Examples/Models/Stocks.ts +60 -0
- package/Examples/Models/User.ts +100 -0
- package/Examples/Models/UserPermission.ts +37 -0
- package/Examples/Models/index.ts +19 -0
- package/Examples/index-keycloack.ts +78 -0
- package/Examples/index.ts +40 -0
- package/Examples/keycloak.json +7 -0
- package/Examples/log/access.log +0 -0
- package/Examples/log/app.log +6057 -0
- package/Examples/log/errors.log +1526 -0
- package/Examples/package.json +46 -0
- package/Examples/tsconfig.json +21 -0
- package/base/ActionFilter.ts +71 -0
- package/base/BaseError.ts +26 -0
- package/base/BaseObject.ts +19 -0
- package/base/Behavior.ts +6 -0
- package/base/Component.ts +66 -0
- package/base/Configurable.ts +10 -0
- package/base/Controller.ts +84 -0
- package/base/DataErrorDbException.ts +16 -0
- package/base/DbConnection.ts +51 -0
- package/base/ForbiddenHttpException.ts +15 -0
- package/base/InvalidConfigException.ts +16 -0
- package/base/Model.ts +358 -0
- package/base/ModelManager.ts +14 -0
- package/base/NotFoundHttpException.ts +14 -0
- package/base/RestClient.ts +28 -0
- package/base/UnauthorizedHttpException.ts +17 -0
- package/base/ValidationHttpException.ts +14 -0
- package/base/db/Exception.ts +14 -0
- package/base/index.ts +17 -0
- package/decorator/Middleware.ts +9 -0
- package/decorator/controller.ts +22 -0
- package/decorator/enums/ControllerDecoratorParams.ts +5 -0
- package/decorator/get.ts +37 -0
- package/decorator/index.ts +3 -0
- package/decorator/post.ts +36 -0
- package/{BaseChyz.js → dist/BaseChyz.js} +29 -4
- package/dist/BaseChyz.js.map +1 -0
- package/{Chyz.js → dist/Chyz.js} +0 -0
- package/{Chyz.js.map → dist/Chyz.js.map} +0 -0
- package/{base → dist/base}/ActionFilter.js +0 -0
- package/{base → dist/base}/ActionFilter.js.map +0 -0
- package/{base → dist/base}/BaseError.js +0 -0
- package/{base → dist/base}/BaseError.js.map +0 -0
- package/{base → dist/base}/BaseObject.js +0 -0
- package/{base → dist/base}/BaseObject.js.map +0 -0
- package/{base → dist/base}/Behavior.js +0 -0
- package/{base → dist/base}/Behavior.js.map +0 -0
- package/{base → dist/base}/Component.js +0 -0
- package/{base → dist/base}/Component.js.map +0 -0
- package/{base → dist/base}/Configurable.js +0 -0
- package/{base → dist/base}/Configurable.js.map +0 -0
- package/{base → dist/base}/Controller.js +0 -0
- package/{base → dist/base}/Controller.js.map +0 -0
- package/{base → dist/base}/DataErrorDbException.js +0 -0
- package/{base → dist/base}/DataErrorDbException.js.map +0 -0
- package/{base → dist/base}/DbConnection.js +0 -0
- package/{base → dist/base}/DbConnection.js.map +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js.map +0 -0
- package/{base → dist/base}/InvalidConfigException.js +0 -0
- package/{base → dist/base}/InvalidConfigException.js.map +0 -0
- package/{base → dist/base}/Model.js +32 -28
- package/dist/base/Model.js.map +1 -0
- package/dist/base/ModelManager.js +17 -0
- package/dist/base/ModelManager.js.map +1 -0
- package/{base → dist/base}/NotFoundHttpException.js +0 -0
- package/{base → dist/base}/NotFoundHttpException.js.map +0 -0
- package/{base → dist/base}/RestClient.js +0 -0
- package/{base → dist/base}/RestClient.js.map +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js.map +0 -0
- package/{base → dist/base}/ValidationHttpException.js +0 -0
- package/{base → dist/base}/ValidationHttpException.js.map +0 -0
- package/{base → dist/base}/db/Exception.js +0 -0
- package/{base → dist/base}/db/Exception.js.map +0 -0
- package/{base → dist/base}/index.js +1 -0
- package/{base → dist/base}/index.js.map +1 -1
- package/{decorator → dist/decorator}/Middleware.js +0 -0
- package/{decorator → dist/decorator}/Middleware.js.map +0 -0
- package/{decorator → dist/decorator}/controller.js +0 -0
- package/{decorator → dist/decorator}/controller.js.map +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js.map +0 -0
- package/{decorator → dist/decorator}/get.js +0 -0
- package/{decorator → dist/decorator}/get.js.map +0 -0
- package/{decorator → dist/decorator}/index.js +0 -0
- package/{decorator → dist/decorator}/index.js.map +0 -0
- package/{decorator → dist/decorator}/post.js +0 -0
- package/{decorator → dist/decorator}/post.js.map +0 -0
- package/{filters → dist/filters}/AccessControl.js +0 -0
- package/{filters → dist/filters}/AccessControl.js.map +0 -0
- package/{filters → dist/filters}/AccessRule.js +0 -0
- package/{filters → dist/filters}/AccessRule.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/index.js +0 -0
- package/{filters → dist/filters}/auth/index.js.map +0 -0
- package/{filters → dist/filters}/index.js +0 -0
- package/{filters → dist/filters}/index.js.map +0 -0
- package/{index.js → dist/index.js} +0 -0
- package/{index.js.map → dist/index.js.map} +0 -0
- package/dist/log/config/log4js.json +55 -0
- package/{model → dist/model}/RouteDefinition.js +0 -0
- package/{model → dist/model}/RouteDefinition.js.map +0 -0
- package/{requiments → dist/requiments}/Glob.js +0 -0
- package/{requiments → dist/requiments}/Glob.js.map +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js.map +0 -0
- package/{requiments → dist/requiments}/Utils.js +0 -0
- package/{requiments → dist/requiments}/Utils.js.map +0 -0
- package/{validators → dist/validators}/BooleanValidator.js +0 -0
- package/{validators → dist/validators}/BooleanValidator.js.map +0 -0
- package/{validators → dist/validators}/CompareValidator.js +0 -0
- package/{validators → dist/validators}/CompareValidator.js.map +0 -0
- package/{validators → dist/validators}/DateValidator.js +0 -0
- package/{validators → dist/validators}/DateValidator.js.map +0 -0
- package/{validators → dist/validators}/EmailValidator.js +0 -0
- package/{validators → dist/validators}/EmailValidator.js.map +0 -0
- package/{validators → dist/validators}/Validator.js +0 -0
- package/{validators → dist/validators}/Validator.js.map +0 -0
- package/{web → dist/web}/IdentityInterface.js +0 -0
- package/{web → dist/web}/IdentityInterface.js.map +0 -0
- package/{web → dist/web}/WebUser.js +0 -0
- package/{web → dist/web}/WebUser.js.map +0 -0
- package/filters/AccessControl.ts +64 -0
- package/filters/AccessRule.ts +137 -0
- package/filters/auth/AuthInterface.ts +34 -0
- package/filters/auth/AuthMethod.ts +88 -0
- package/filters/auth/HttpBasicAuth.ts +7 -0
- package/filters/auth/HttpBearerAuth.ts +31 -0
- package/filters/auth/HttpHeaderAuth.ts +53 -0
- package/filters/auth/JwtHttpBearerAuth.ts +80 -0
- package/filters/auth/KeyCloakHttpBearerAuth.ts +115 -0
- package/filters/auth/index.ts +3 -0
- package/filters/index.ts +2 -0
- package/index.ts +14 -0
- package/model/RouteDefinition.ts +18 -0
- package/package-lock.json +5259 -0
- package/package.json +3 -3
- package/requiments/Glob.ts +9 -0
- package/requiments/ReflectUtil.ts +26 -0
- package/requiments/Utils.ts +57 -0
- package/tsconfig.json +18 -0
- package/validators/BooleanValidator.ts +0 -0
- package/validators/CompareValidator.ts +0 -0
- package/validators/DateValidator.ts +0 -0
- package/validators/EmailValidator.ts +0 -0
- package/validators/Validator.ts +27 -0
- package/web/IdentityInterface.ts +62 -0
- package/web/WebUser.ts +100 -0
- package/BaseChyz.js.map +0 -1
- package/base/Model.js.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
// @ts-ignore
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import {IdentityInterface} from "../../web/IdentityInterface";
|
|
11
|
+
import {DataTypes, Model} from "../../base";
|
|
12
|
+
import {BaseChyz} from "../../index";
|
|
13
|
+
|
|
14
|
+
const JsonWebToken = require("jsonwebtoken");
|
|
15
|
+
|
|
16
|
+
export class User extends Model implements IdentityInterface {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
|
|
19
|
+
public tableName() {
|
|
20
|
+
return 'users';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
findIdentity(id: number) {
|
|
24
|
+
throw new Error("Method not implemented.");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getId(): number {
|
|
28
|
+
throw new Error("Method not implemented.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getAuthKey(): string {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
validateAuthKey(authKey: string): boolean {
|
|
36
|
+
throw new Error("Method not implemented.");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public attributes() {
|
|
40
|
+
return {
|
|
41
|
+
// Model attributes are defined here
|
|
42
|
+
name: {
|
|
43
|
+
type: DataTypes.STRING,
|
|
44
|
+
allowNull: false
|
|
45
|
+
},
|
|
46
|
+
username: {
|
|
47
|
+
type: DataTypes.STRING,
|
|
48
|
+
allowNull: false
|
|
49
|
+
},
|
|
50
|
+
password: {
|
|
51
|
+
type: DataTypes.STRING,
|
|
52
|
+
allowNull: false
|
|
53
|
+
},
|
|
54
|
+
email: {
|
|
55
|
+
type: DataTypes.STRING,
|
|
56
|
+
allowNull: false
|
|
57
|
+
},
|
|
58
|
+
permissions_id: {
|
|
59
|
+
type: DataTypes.INTEGER,
|
|
60
|
+
allowNull: false
|
|
61
|
+
},
|
|
62
|
+
authkey: {
|
|
63
|
+
type: DataTypes.STRING
|
|
64
|
+
// allowNull defaults to true
|
|
65
|
+
},
|
|
66
|
+
status: {
|
|
67
|
+
type: DataTypes.STRING
|
|
68
|
+
// allowNull defaults to true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async findIdentityByAccessToken(token, type) {
|
|
74
|
+
let decoded = JsonWebToken.decode(token, {complete: true})
|
|
75
|
+
|
|
76
|
+
if(!decoded.payload.user) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let identity = await this.findOne({where: {id: parseInt(decoded.payload.user)}});
|
|
81
|
+
if (identity) {
|
|
82
|
+
BaseChyz.debug("Find Identity By AccessToken: User Found", decoded.payload)
|
|
83
|
+
try {
|
|
84
|
+
JsonWebToken.verify(token, identity.authkey);
|
|
85
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Success")
|
|
86
|
+
return identity;
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (err.name == "TokenExpiredError")
|
|
89
|
+
BaseChyz.debug("Find Identity By AccessToken: Token Expired")
|
|
90
|
+
else
|
|
91
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
// @ts-ignore
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import {DataTypes, Model} from "../../base";
|
|
11
|
+
|
|
12
|
+
export class UserPermissionClass extends Model {
|
|
13
|
+
[x: string]: any;
|
|
14
|
+
|
|
15
|
+
public tableName() {
|
|
16
|
+
return 'user_permissions';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
public attributes() {
|
|
21
|
+
return {
|
|
22
|
+
// Model attributes are defined here
|
|
23
|
+
object_type: {
|
|
24
|
+
type: DataTypes.STRING,
|
|
25
|
+
allowNull: false
|
|
26
|
+
},
|
|
27
|
+
object_value: {
|
|
28
|
+
type: DataTypes.STRING,
|
|
29
|
+
allowNull: false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// const UserPermission = new UserPermissionClass();
|
|
37
|
+
// export {UserPermission}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
4
|
+
* Author: Cihan Ozturk
|
|
5
|
+
* E-mail: cihan@chy.com.tr
|
|
6
|
+
* Github:https://github.com/cihan53/
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import {ModelManager} from "../../base";
|
|
10
|
+
// import {Order, OrderClass} from "./Order";
|
|
11
|
+
// import {Customer, CustomerClass} from "./Customer";
|
|
12
|
+
// import {Products} from "./Products";
|
|
13
|
+
// import {ProductModels} from "./ProductModels";
|
|
14
|
+
// import {Categories} from "./Categories";
|
|
15
|
+
// import {ProductToCategories} from "./ProductToCategories";
|
|
16
|
+
//
|
|
17
|
+
// Dependencies._register({Order, Customer,CustomerClass,OrderClass, Products, ProductModels, Categories, ProductToCategories});
|
|
18
|
+
//
|
|
19
|
+
// console.log("denmemem")
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
require('dotenv-flow').config();
|
|
10
|
+
|
|
11
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
12
|
+
|
|
13
|
+
import Chyz from "../Chyz";
|
|
14
|
+
import {WebUser} from "../web/WebUser";
|
|
15
|
+
import {KeycloakUser as Identity} from "./Models/KeycloakUser";
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
import {DbConnection} from "../base/DbConnection";
|
|
18
|
+
|
|
19
|
+
var Keycloak = require('keycloak-connect');
|
|
20
|
+
var session = require('express-session');
|
|
21
|
+
var memoryStore = new session.MemoryStore();
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var keycloakConfig = {
|
|
25
|
+
"realm": "CameraBox",
|
|
26
|
+
"auth-server-url": "https://keycloak.hubbox.io:8080/auth/",
|
|
27
|
+
//"ssl-required": "external",
|
|
28
|
+
"resource": "izanami",
|
|
29
|
+
"verify-token-audience": true,
|
|
30
|
+
"bearerOnly": true,
|
|
31
|
+
"confidential-port":0,
|
|
32
|
+
"policy-enforcer":{},
|
|
33
|
+
"credentials": {
|
|
34
|
+
"secret": "0b476571-28ab-49b1-9968-90fce6294d5a"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Keycloak.prototype.accessDenied = function () {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var keycloak = new Keycloak({scope: 'offline_access'}, keycloakConfig);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
let config = {
|
|
49
|
+
port: 3000,
|
|
50
|
+
controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
|
|
51
|
+
components: {
|
|
52
|
+
db: {
|
|
53
|
+
class: DbConnection,
|
|
54
|
+
database: process.env.DBDATABASE,
|
|
55
|
+
username: process.env.DBUSER,
|
|
56
|
+
password: process.env.DBPASS,
|
|
57
|
+
options: {
|
|
58
|
+
host: process.env.DBHOST,
|
|
59
|
+
dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
|
|
60
|
+
// disable logging; default: console.log
|
|
61
|
+
logging: false
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
user: {
|
|
65
|
+
'class': WebUser,
|
|
66
|
+
'identityClass': Identity
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
middlewares: {
|
|
70
|
+
keycloak: {
|
|
71
|
+
keycloak: keycloak,
|
|
72
|
+
config: {
|
|
73
|
+
logout: '/logout'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
Chyz.app(config).Start();
|
|
@@ -0,0 +1,40 @@
|
|
|
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 {BaseChyz} from "../index";
|
|
10
|
+
require('dotenv-flow').config();
|
|
11
|
+
import Chyz from "../Chyz";
|
|
12
|
+
import {WebUser} from "../web/WebUser";
|
|
13
|
+
import {User} from "./Models/User";
|
|
14
|
+
import {DbConnection} from "../base";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
let config = {
|
|
18
|
+
port: process.env.PORT,
|
|
19
|
+
controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
|
|
20
|
+
components: {
|
|
21
|
+
db: {
|
|
22
|
+
class: DbConnection,
|
|
23
|
+
database: process.env.DBDATABASE,
|
|
24
|
+
username: process.env.DBUSER,
|
|
25
|
+
password: process.env.DBPASS,
|
|
26
|
+
options: {
|
|
27
|
+
host: process.env.DBHOST,
|
|
28
|
+
dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
|
|
29
|
+
// disable logging; default: console.log
|
|
30
|
+
logging: (msg: any) => BaseChyz.debug(msg)
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
user: {
|
|
34
|
+
'class': WebUser,
|
|
35
|
+
'identityClass': User
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
Chyz.app(config).Start();
|
|
File without changes
|