chyz 1.0.13-rc.9 → 1.1.0-rc.2

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.
Files changed (71) hide show
  1. package/BaseChyz.ts +74 -20
  2. package/Doc/Moel kullanma.md +13 -0
  3. package/Examples/Controllers/ApiController.ts +22 -22
  4. package/Examples/Controllers/BasicApiController.ts +121 -0
  5. package/Examples/Controllers/SiteController.ts +18 -8
  6. package/Examples/Models/AuthAssignment.ts +50 -0
  7. package/Examples/Models/AuthItem.ts +59 -0
  8. package/Examples/Models/AuthItemChild.ts +49 -0
  9. package/Examples/Models/Categories.ts +4 -0
  10. package/Examples/Models/KeycloakUser.ts +4 -0
  11. package/Examples/Models/User.ts +30 -2
  12. package/Examples/index.ts +22 -2
  13. package/Examples/log/app.log +14466 -0
  14. package/Examples/log/errors.log +594 -0
  15. package/Examples/package.json +5 -2
  16. package/README.md +265 -12
  17. package/base/ActionFilter.ts +1 -1
  18. package/base/BaseError.ts +4 -2
  19. package/base/DbConnection.ts +9 -5
  20. package/base/Model.ts +231 -30
  21. package/base/ModelManager.ts +6 -1
  22. package/base/RestClient.ts +4 -4
  23. package/base/ValidationHttpException.ts +1 -1
  24. package/dist/BaseChyz.js +61 -14
  25. package/dist/BaseChyz.js.map +1 -1
  26. package/dist/base/ActionFilter.js +1 -1
  27. package/dist/base/ActionFilter.js.map +1 -1
  28. package/dist/base/BaseError.js +6 -2
  29. package/dist/base/BaseError.js.map +1 -1
  30. package/dist/base/DbConnection.js +1 -0
  31. package/dist/base/DbConnection.js.map +1 -1
  32. package/dist/base/Model.js +192 -4
  33. package/dist/base/Model.js.map +1 -1
  34. package/dist/base/ModelManager.js +0 -8
  35. package/dist/base/ModelManager.js.map +1 -1
  36. package/dist/base/RestClient.js +4 -4
  37. package/dist/base/RestClient.js.map +1 -1
  38. package/dist/base/ValidationHttpException.js +1 -1
  39. package/dist/filters/AccessControl.js +15 -3
  40. package/dist/filters/AccessControl.js.map +1 -1
  41. package/dist/filters/AccessRule.js +99 -38
  42. package/dist/filters/AccessRule.js.map +1 -1
  43. package/dist/filters/auth/HttpBasicAuth.js +65 -0
  44. package/dist/filters/auth/HttpBasicAuth.js.map +1 -1
  45. package/dist/filters/auth/index.js +1 -0
  46. package/dist/filters/auth/index.js.map +1 -1
  47. package/dist/package.json +6 -4
  48. package/dist/rbac/AuthAssignment.js +45 -0
  49. package/dist/rbac/AuthAssignment.js.map +1 -0
  50. package/dist/rbac/AuthItem.js +52 -0
  51. package/dist/rbac/AuthItem.js.map +1 -0
  52. package/dist/rbac/AuthItemChild.js +44 -0
  53. package/dist/rbac/AuthItemChild.js.map +1 -0
  54. package/dist/rbac/AuthManager.js +13 -5
  55. package/dist/rbac/AuthManager.js.map +1 -1
  56. package/dist/requiments/Utils.js +5 -1
  57. package/dist/requiments/Utils.js.map +1 -1
  58. package/dist/web/WebUser.js +78 -0
  59. package/dist/web/WebUser.js.map +1 -1
  60. package/filters/AccessControl.ts +19 -6
  61. package/filters/AccessRule.ts +61 -16
  62. package/filters/auth/HttpBasicAuth.ts +68 -0
  63. package/filters/auth/index.ts +1 -0
  64. package/package.json +6 -4
  65. package/rbac/AuthAssignment.ts +50 -0
  66. package/rbac/AuthItem.ts +57 -0
  67. package/rbac/AuthItemChild.ts +50 -0
  68. package/rbac/AuthManager.ts +19 -9
  69. package/requiments/Utils.ts +6 -0
  70. package/web/IdentityInterface.ts +7 -1
  71. package/web/WebUser.ts +88 -1
@@ -16,18 +16,41 @@ const JsonWebToken = require("jsonwebtoken");
16
16
  export class User extends Model implements IdentityInterface {
17
17
  [x: string]: any;
18
18
 
19
+ /**
20
+ *
21
+ */
19
22
  public tableName() {
20
23
  return 'users';
21
24
  }
22
25
 
26
+ /**
27
+ *
28
+ * @param id
29
+ */
23
30
  findIdentity(id: number) {
24
31
  throw new Error("Method not implemented.");
25
32
  }
26
33
 
34
+ /**
35
+ *
36
+ */
27
37
  getId(): number {
28
38
  throw new Error("Method not implemented.");
29
39
  }
30
40
 
41
+ /**
42
+ *
43
+ * @param permissionName
44
+ * @param params
45
+ * @param allowCaching
46
+ */
47
+ can(permissionName: string, params: any[], allowCaching: boolean): boolean | null {
48
+ throw new Error("Method not implemented.");
49
+ }
50
+
51
+ /**
52
+ *
53
+ */
31
54
  getAuthKey(): string {
32
55
  throw new Error("Method not implemented.");
33
56
  }
@@ -36,6 +59,9 @@ export class User extends Model implements IdentityInterface {
36
59
  throw new Error("Method not implemented.");
37
60
  }
38
61
 
62
+ /**
63
+ *
64
+ */
39
65
  public attributes() {
40
66
  return {
41
67
  // Model attributes are defined here
@@ -71,8 +97,8 @@ export class User extends Model implements IdentityInterface {
71
97
  }
72
98
 
73
99
  async findIdentityByAccessToken(token, type) {
74
- let decoded = JsonWebToken.decode(token, {complete: true})
75
100
 
101
+ let decoded = JsonWebToken.decode(token, {complete: true})
76
102
  if(!decoded.payload.user) {
77
103
  return null;
78
104
  }
@@ -97,4 +123,6 @@ export class User extends Model implements IdentityInterface {
97
123
  }
98
124
 
99
125
 
100
- }
126
+
127
+
128
+ }
package/Examples/index.ts CHANGED
@@ -7,22 +7,27 @@
7
7
 
8
8
 
9
9
  import {BaseChyz} from "../index";
10
- require('dotenv-flow').config();
11
10
  import Chyz from "../Chyz";
12
11
  import {WebUser} from "../web/WebUser";
13
12
  import {User} from "./Models/User";
14
13
  import {DbConnection} from "../base";
14
+ import {AuthManager} from "../rbac/AuthManager";
15
+
16
+ require('dotenv-flow').config();
17
+
15
18
 
16
19
 
17
20
  let config = {
18
21
  port: process.env.PORT,
19
- controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
22
+ controllerpath: process.env.CONTROLLER_PATH,
20
23
  components: {
24
+
21
25
  db: {
22
26
  class: DbConnection,
23
27
  database: process.env.DBDATABASE,
24
28
  username: process.env.DBUSER,
25
29
  password: process.env.DBPASS,
30
+
26
31
  options: {
27
32
  host: process.env.DBHOST,
28
33
  dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
@@ -30,6 +35,21 @@ let config = {
30
35
  logging: (msg: any) => BaseChyz.debug(msg)
31
36
  }
32
37
  },
38
+ db2: {
39
+ class: DbConnection,
40
+ database: process.env.DBDATABASE,
41
+ username: process.env.DBUSER,
42
+ password: process.env.DBPASS,
43
+ options: {
44
+ host: process.env.DBHOST,
45
+ dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
46
+ // disable logging; default: console.log
47
+ logging: (msg: any) => BaseChyz.debug('DB2', msg)
48
+ }
49
+ },
50
+ authManager: {
51
+ class: AuthManager,
52
+ },
33
53
  user: {
34
54
  'class': WebUser,
35
55
  'identityClass': User