chyz 1.2.4-rc.1 → 1.2.4-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 (179) hide show
  1. package/{dist/BaseChyz.js → BaseChyz.js} +0 -0
  2. package/{dist/BaseChyz.js.map → BaseChyz.js.map} +0 -0
  3. package/{dist/Chyz.js → Chyz.js} +0 -0
  4. package/{dist/Chyz.js.map → Chyz.js.map} +0 -0
  5. package/{dist/base → base}/ActionFilter.js +0 -0
  6. package/{dist/base → base}/ActionFilter.js.map +0 -0
  7. package/{dist/base → base}/BaseError.js +0 -0
  8. package/{dist/base → base}/BaseError.js.map +0 -0
  9. package/{dist/base → base}/BaseObject.js +0 -0
  10. package/{dist/base → base}/BaseObject.js.map +0 -0
  11. package/{dist/base → base}/Behavior.js +0 -0
  12. package/{dist/base → base}/Behavior.js.map +0 -0
  13. package/{dist/base → base}/CWebController.js +0 -0
  14. package/{dist/base → base}/CWebController.js.map +0 -0
  15. package/{dist/base → base}/Component.js +0 -0
  16. package/{dist/base → base}/Component.js.map +0 -0
  17. package/{dist/base → base}/Configurable.js +0 -0
  18. package/{dist/base → base}/Configurable.js.map +0 -0
  19. package/{dist/base → base}/DataErrorDbException.js +0 -0
  20. package/{dist/base → base}/DataErrorDbException.js.map +0 -0
  21. package/{dist/base → base}/DbConnection.js +0 -0
  22. package/{dist/base → base}/DbConnection.js.map +0 -0
  23. package/{dist/base → base}/ForbiddenHttpException.js +0 -0
  24. package/{dist/base → base}/ForbiddenHttpException.js.map +0 -0
  25. package/{dist/base → base}/InvalidArgumentException.js +0 -0
  26. package/{dist/base → base}/InvalidArgumentException.js.map +0 -0
  27. package/{dist/base → base}/InvalidConfigException.js +0 -0
  28. package/{dist/base → base}/InvalidConfigException.js.map +0 -0
  29. package/{dist/base → base}/Model.js +0 -0
  30. package/{dist/base → base}/Model.js.map +0 -0
  31. package/{dist/base → base}/ModelManager.js +0 -0
  32. package/{dist/base → base}/ModelManager.js.map +0 -0
  33. package/{dist/base → base}/NotFoundHttpException.js +0 -0
  34. package/{dist/base → base}/NotFoundHttpException.js.map +0 -0
  35. package/{dist/base → base}/RestClient.js +0 -0
  36. package/{dist/base → base}/RestClient.js.map +0 -0
  37. package/{dist/base → base}/UnauthorizedHttpException.js +0 -0
  38. package/{dist/base → base}/UnauthorizedHttpException.js.map +0 -0
  39. package/{dist/base → base}/ValidationHttpException.js +0 -0
  40. package/{dist/base → base}/ValidationHttpException.js.map +0 -0
  41. package/{dist/base → base}/db/Exception.js +0 -0
  42. package/{dist/base → base}/db/Exception.js.map +0 -0
  43. package/{dist/base → base}/index.js +0 -0
  44. package/{dist/base → base}/index.js.map +0 -0
  45. package/{dist/decorator → decorator}/Middleware.js +0 -0
  46. package/{dist/decorator → decorator}/Middleware.js.map +0 -0
  47. package/{dist/decorator → decorator}/controller.js +0 -0
  48. package/{dist/decorator → decorator}/controller.js.map +0 -0
  49. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js +0 -0
  50. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js.map +0 -0
  51. package/{dist/decorator → decorator}/get.js +0 -0
  52. package/{dist/decorator → decorator}/get.js.map +0 -0
  53. package/{dist/decorator → decorator}/index.js +0 -0
  54. package/{dist/decorator → decorator}/index.js.map +0 -0
  55. package/{dist/decorator → decorator}/post.js +0 -0
  56. package/{dist/decorator → decorator}/post.js.map +0 -0
  57. package/{dist/filters → filters}/AccessControl.js +0 -0
  58. package/{dist/filters → filters}/AccessControl.js.map +0 -0
  59. package/{dist/filters → filters}/AccessRule.js +0 -0
  60. package/{dist/filters → filters}/AccessRule.js.map +0 -0
  61. package/{dist/filters → filters}/auth/AuthInterface.js +0 -0
  62. package/{dist/filters → filters}/auth/AuthInterface.js.map +0 -0
  63. package/{dist/filters → filters}/auth/AuthMethod.js +0 -0
  64. package/{dist/filters → filters}/auth/AuthMethod.js.map +0 -0
  65. package/{dist/filters → filters}/auth/HttpBasicAuth.js +0 -0
  66. package/{dist/filters → filters}/auth/HttpBasicAuth.js.map +0 -0
  67. package/{dist/filters → filters}/auth/HttpBearerAuth.js +0 -0
  68. package/{dist/filters → filters}/auth/HttpBearerAuth.js.map +0 -0
  69. package/{dist/filters → filters}/auth/HttpHeaderAuth.js +0 -0
  70. package/{dist/filters → filters}/auth/HttpHeaderAuth.js.map +0 -0
  71. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js +0 -0
  72. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js.map +0 -0
  73. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
  74. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
  75. package/{dist/filters → filters}/auth/index.js +0 -0
  76. package/{dist/filters → filters}/auth/index.js.map +0 -0
  77. package/{dist/filters → filters}/index.js +0 -0
  78. package/{dist/filters → filters}/index.js.map +0 -0
  79. package/{dist/index.js → index.js} +0 -0
  80. package/{dist/index.js.map → index.js.map} +0 -0
  81. package/{dist/model → model}/RouteDefinition.js +0 -0
  82. package/{dist/model → model}/RouteDefinition.js.map +0 -0
  83. package/package.json +2 -2
  84. package/{dist/rbac → rbac}/AuthAssignment.js +0 -0
  85. package/{dist/rbac → rbac}/AuthAssignment.js.map +0 -0
  86. package/{dist/rbac → rbac}/AuthItem.js +0 -0
  87. package/{dist/rbac → rbac}/AuthItem.js.map +0 -0
  88. package/{dist/rbac → rbac}/AuthItemChild.js +0 -0
  89. package/{dist/rbac → rbac}/AuthItemChild.js.map +0 -0
  90. package/{dist/rbac → rbac}/AuthManager.js +0 -0
  91. package/{dist/rbac → rbac}/AuthManager.js.map +0 -0
  92. package/{dist/requiments → requiments}/Glob.js +0 -0
  93. package/{dist/requiments → requiments}/Glob.js.map +0 -0
  94. package/{dist/requiments → requiments}/ReflectUtil.js +0 -0
  95. package/{dist/requiments → requiments}/ReflectUtil.js.map +0 -0
  96. package/{dist/requiments → requiments}/Utils.js +0 -0
  97. package/{dist/requiments → requiments}/Utils.js.map +0 -0
  98. package/{dist/validators → validators}/BooleanValidator.js +0 -0
  99. package/{dist/validators → validators}/BooleanValidator.js.map +0 -0
  100. package/{dist/validators → validators}/CompareValidator.js +0 -0
  101. package/{dist/validators → validators}/CompareValidator.js.map +0 -0
  102. package/{dist/validators → validators}/DateValidator.js +0 -0
  103. package/{dist/validators → validators}/DateValidator.js.map +0 -0
  104. package/{dist/validators → validators}/EmailValidator.js +0 -0
  105. package/{dist/validators → validators}/EmailValidator.js.map +0 -0
  106. package/{dist/validators → validators}/Validator.js +0 -0
  107. package/{dist/validators → validators}/Validator.js.map +0 -0
  108. package/{dist/web → web}/IdentityInterface.js +0 -0
  109. package/{dist/web → web}/IdentityInterface.js.map +0 -0
  110. package/{dist/web → web}/WebUser.js +0 -0
  111. package/{dist/web → web}/WebUser.js.map +0 -0
  112. package/BaseChyz.ts +0 -454
  113. package/Chyz.ts +0 -11
  114. package/Doc/Git.md +0 -29
  115. package/Doc/Moel kullanma.md +0 -13
  116. package/Examples/Controllers/ApiController.ts +0 -110
  117. package/Examples/Models/User.ts +0 -122
  118. package/Examples/index-keycloack.ts +0 -78
  119. package/Examples/index.ts +0 -60
  120. package/Examples/keycloak.json +0 -7
  121. package/Examples/package.json +0 -49
  122. package/Examples/tsconfig.json +0 -21
  123. package/base/ActionFilter.ts +0 -71
  124. package/base/BaseError.ts +0 -28
  125. package/base/BaseObject.ts +0 -19
  126. package/base/Behavior.ts +0 -6
  127. package/base/CWebController.ts +0 -84
  128. package/base/Component.ts +0 -66
  129. package/base/Configurable.ts +0 -10
  130. package/base/DataErrorDbException.ts +0 -16
  131. package/base/DbConnection.ts +0 -55
  132. package/base/ForbiddenHttpException.ts +0 -15
  133. package/base/InvalidArgumentException.ts +0 -16
  134. package/base/InvalidConfigException.ts +0 -16
  135. package/base/Model.ts +0 -555
  136. package/base/ModelManager.ts +0 -19
  137. package/base/NotFoundHttpException.ts +0 -14
  138. package/base/RestClient.ts +0 -28
  139. package/base/UnauthorizedHttpException.ts +0 -17
  140. package/base/ValidationHttpException.ts +0 -14
  141. package/base/db/Exception.ts +0 -14
  142. package/base/index.ts +0 -18
  143. package/decorator/Middleware.ts +0 -9
  144. package/decorator/controller.ts +0 -22
  145. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  146. package/decorator/get.ts +0 -37
  147. package/decorator/index.ts +0 -3
  148. package/decorator/post.ts +0 -36
  149. package/dist/log/config/log4js.json +0 -55
  150. package/dist/package.json +0 -59
  151. package/filters/AccessControl.ts +0 -74
  152. package/filters/AccessRule.ts +0 -182
  153. package/filters/auth/AuthInterface.ts +0 -34
  154. package/filters/auth/AuthMethod.ts +0 -89
  155. package/filters/auth/HttpBasicAuth.ts +0 -75
  156. package/filters/auth/HttpBearerAuth.ts +0 -31
  157. package/filters/auth/HttpHeaderAuth.ts +0 -53
  158. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  159. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  160. package/filters/auth/index.ts +0 -4
  161. package/filters/index.ts +0 -2
  162. package/index.ts +0 -16
  163. package/model/RouteDefinition.ts +0 -18
  164. package/package-lock.json +0 -5259
  165. package/rbac/AuthAssignment.ts +0 -50
  166. package/rbac/AuthItem.ts +0 -57
  167. package/rbac/AuthItemChild.ts +0 -50
  168. package/rbac/AuthManager.ts +0 -398
  169. package/requiments/Glob.ts +0 -9
  170. package/requiments/ReflectUtil.ts +0 -26
  171. package/requiments/Utils.ts +0 -63
  172. package/tsconfig.json +0 -18
  173. package/validators/BooleanValidator.ts +0 -0
  174. package/validators/CompareValidator.ts +0 -0
  175. package/validators/DateValidator.ts +0 -0
  176. package/validators/EmailValidator.ts +0 -0
  177. package/validators/Validator.ts +0 -27
  178. package/web/IdentityInterface.ts +0 -68
  179. package/web/WebUser.ts +0 -187
@@ -1,89 +0,0 @@
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 {ActionFilter} from "../../base/ActionFilter";
9
- import {AuthInterface} from "./AuthInterface";
10
- import {UnauthorizedHttpException} from "../../base/UnauthorizedHttpException";
11
- import {WebUser} from "../../web/WebUser";
12
- import {Request, Response} from "express";
13
-
14
- export abstract class AuthMethod extends ActionFilter implements AuthInterface {
15
-
16
- /**
17
- * @var User the user object representing the user authentication status. If not set, the `user` application component will be used.
18
- */
19
- public user: WebUser | undefined;
20
-
21
- /**
22
- * @var Request the current request. If not set, the `request` application component will be used.
23
- */
24
- public request: Request | undefined;
25
-
26
- /**
27
- * @var Response the response to be sent. If not set, the `response` application component will be used.
28
- */
29
- public response: Response | undefined;
30
-
31
-
32
- public optional = [];
33
-
34
- public async beforeAction(action: any, request: Request, response: Response) {
35
- let identity = await this.authenticate(
36
- this.user ?? new WebUser(),
37
- request,
38
- response
39
- )
40
-
41
-
42
- // @ts-ignore
43
- request.identity = identity;
44
-
45
- if (identity !== null) {
46
- return true;
47
- }
48
-
49
- this.challenge(response);
50
- this.handleFailure(response);
51
- return false;
52
- }
53
-
54
- authenticate(user: WebUser, request: Request, response: Response) {
55
-
56
- }
57
-
58
- // @ts-ignore
59
- challenge(response: Response): void {
60
-
61
- }
62
-
63
- // @ts-ignore
64
- handleFailure(response: Response) {
65
- throw new UnauthorizedHttpException('Your request was made with invalid credentials.');
66
- }
67
-
68
- getHeaderByKey(headers: any, findKey: any) {
69
- let key = Object.keys(headers).find(key => key.toLowerCase() === findKey.toLowerCase())
70
- if (key) {
71
- return headers[key];
72
- }
73
-
74
- return null
75
- }
76
-
77
- patternCheck(headerText:any, pattern:RegExp) {
78
- if (pattern) {
79
- let matches = headerText.match(pattern)
80
- if (matches && matches.length > 0) {
81
- return matches;
82
- } else {
83
- return null
84
- }
85
- }
86
-
87
- return null
88
- }
89
- }
@@ -1,75 +0,0 @@
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 {HttpHeaderAuth} from "./HttpHeaderAuth";
9
- import {Request, Response} from "express";
10
- import {WebUser} from "../../web/WebUser";
11
- import Utils from "../../requiments/Utils";
12
- import {AuthMethod} from "./AuthMethod";
13
- import {InvalidConfigException} from "../../base";
14
- import BaseChyz from "../../BaseChyz";
15
-
16
- export class HttpBasicAuth extends AuthMethod {
17
-
18
- /**
19
- * @var string the HTTP header name
20
- */
21
- public header = 'Authorization';
22
-
23
-
24
- /**
25
- * @var string a pattern to use to extract the HTTP authentication value
26
- */
27
-
28
- public pattern = /^Basic\s+(.*?)$/;
29
-
30
-
31
- /**
32
- * @throws InvalidConfigException
33
- */
34
- public init(): void {
35
- super.init();
36
-
37
- if (!this.pattern) {
38
- throw new InvalidConfigException('You must provide pattern to use to extract the HTTP authentication value!');
39
- }
40
-
41
- this.user = BaseChyz.getComponent("user") ?? null;
42
- }
43
-
44
-
45
- async authenticate(user: WebUser, request:Request, response:Response) {
46
-
47
-
48
- let autHeader = this.getHeaderByKey(request.headers, this.header)
49
- if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
50
- return null;
51
- }
52
-
53
- let basicauth = autHeader[1].split(":")
54
-
55
- let identity = await user.loginByAccessToken(basicauth, "HttpBasicAuth");
56
- if (identity === null) {
57
- this.challenge(response);
58
- this.handleFailure(response);
59
- }
60
-
61
- return identity;
62
-
63
-
64
- return null;
65
- }
66
-
67
-
68
- /**
69
- * @throws UnauthorizedHttpException
70
- */
71
- public fail(response:Response): void {
72
- this.challenge(response)
73
- this.handleFailure(response);
74
- }
75
- }
@@ -1,31 +0,0 @@
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 {HttpHeaderAuth} from "./HttpHeaderAuth";
9
- import {Request, Response} from "express";
10
-
11
- export class HttpBearerAuth extends HttpHeaderAuth {
12
-
13
- /**
14
- * {@inheritdoc}
15
- */
16
- public header = 'Authorization';
17
- // @ts-ignore
18
- public pattern = /^Bearer\s+(.*?)$/;
19
- /**
20
- * @var string the HTTP authentication realm
21
- */
22
- public realm = 'api';
23
-
24
-
25
- /**
26
- * {@inheritdoc}
27
- */
28
- public challenge(response:Response) {
29
- response.set('WWW-Authenticate', `Bearer realm="${this.realm}"`);
30
- }
31
- }
@@ -1,53 +0,0 @@
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 {AuthMethod} from "./AuthMethod";
9
- import {WebUser} from "../../web/WebUser";
10
- import Utils from "../../requiments/Utils";
11
- import {Request, Response} from "express";
12
-
13
- export class HttpHeaderAuth extends AuthMethod {
14
- /**
15
- * @var string the HTTP header name
16
- */
17
- public header = 'X-Api-Key';
18
-
19
-
20
- /**
21
- * @var string a pattern to use to extract the HTTP authentication value
22
- */
23
-
24
- public pattern!: string;
25
-
26
-
27
- async authenticate(user: WebUser, request:Request, response:Response) {
28
- let key = Object.keys(request.headers).find(key => key.toLowerCase() === this.header.toLowerCase())
29
- if (key) {
30
- let authHeader:any = request.headers[key];
31
- if (!Utils.isEmpty(authHeader)) {
32
- if (this.pattern) {
33
- //preg_match
34
- let matches = authHeader.match(this.pattern)
35
- if (matches && matches.length > 0) {
36
- authHeader = matches[1];
37
- } else {
38
- return null;
39
- }
40
- }
41
-
42
- let identity = await user.loginByAccessToken(authHeader, "HttpHeaderAuth");
43
- if (identity === null) {
44
- this.challenge(response);
45
- this.handleFailure(response);
46
- }
47
-
48
- return identity;
49
- }
50
- }
51
- return null;
52
- }
53
- }
@@ -1,80 +0,0 @@
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
- import BaseChyz from "../../BaseChyz";
8
- import {HttpBearerAuth} from "./HttpBearerAuth";
9
- import {InvalidConfigException} from "../../base/InvalidConfigException";
10
- import {UnauthorizedHttpException} from "../../base/UnauthorizedHttpException";
11
- import {Response,Request} from "express";
12
- import {WebUser} from "../../web/WebUser";
13
-
14
- const JsonWebToken = require("jsonwebtoken");
15
-
16
- export class JwtHttpBearerAuth extends HttpBearerAuth {
17
- /**
18
- * @var string|array<string, mixed>|Jwt application component ID of the JWT handler, configuration array, or JWT handler object
19
- * itself. By default it's assumes that component of ID "jwt" has been configured.
20
- */
21
- public jwt = 'jwt'
22
- public auth:any = null;
23
-
24
-
25
- /**
26
- * @throws InvalidConfigException
27
- */
28
- public init(): void {
29
- super.init();
30
-
31
- if (!this.pattern) {
32
- throw new InvalidConfigException('You must provide pattern to use to extract the HTTP authentication value!');
33
- }
34
-
35
- this.user = BaseChyz.getComponent("user") ?? null;
36
- }
37
-
38
-
39
- public async authenticate(user:WebUser, request:Request, response:Response) // BC signature
40
- {
41
-
42
- let autHeader = this.getHeaderByKey(request.headers, this.header)
43
- if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
44
- return null;
45
- }
46
-
47
-
48
- let identity = null;
49
- let token = null;
50
-
51
- token = JsonWebToken.decode(autHeader[1], {complete: true})
52
- if (!token) {
53
- BaseChyz.warning("Your request was made with invalid or expired JSON Web Token.");
54
- this.fail(response);
55
- }
56
-
57
- if (token !== null) {
58
- if (this.auth != null) {
59
- identity = await this.auth(autHeader[1],...arguments)
60
- } else {
61
- identity = await user.loginByAccessToken(autHeader[1], "JwtHttpBearerAuth")
62
- }
63
- }
64
-
65
- if (identity == null) this.fail(response)
66
-
67
-
68
- return identity;
69
- }
70
-
71
-
72
- /**
73
- * @throws UnauthorizedHttpException
74
- */
75
- public fail(response:Response): void {
76
- this.challenge(response)
77
- this.handleFailure(response);
78
- }
79
-
80
- }
@@ -1,115 +0,0 @@
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
- import BaseChyz from "../../BaseChyz";
8
- import {HttpBearerAuth} from "./HttpBearerAuth";
9
- import {InvalidConfigException} from "../../base/InvalidConfigException";
10
- import {UnauthorizedHttpException} from "../../base/UnauthorizedHttpException";
11
- import {Response, Request} from "express";
12
- import {WebUser} from "../../web/WebUser";
13
-
14
- const JsonWebToken = require("jsonwebtoken");
15
-
16
- export class KeyCloakHttpBearerAuth extends HttpBearerAuth {
17
- /**
18
- * @var string|array<string, mixed>|Jwt application component ID of the JWT handler, configuration array, or JWT handler object
19
- * itself. By default it's assumes that component of ID "jwt" has been configured.
20
- */
21
- public jwt = 'jwt'
22
- public auth: any = null;
23
- public keycloak: any = null;
24
-
25
-
26
- /**
27
- * @throws InvalidConfigException
28
- */
29
- public init(): void {
30
- super.init();
31
-
32
- if (!this.pattern) {
33
- throw new InvalidConfigException('You must provide pattern to use to extract the HTTP authentication value!');
34
- }
35
-
36
- this.keycloak = BaseChyz.getMiddlewares("keycloak").keycloak ?? null;
37
- this.user = BaseChyz.getComponent("user") ?? null;
38
- this.auth = this.KeyCloakCheck;
39
-
40
-
41
- }
42
-
43
- public async KeyCloakCheck(token: string, request: Request, response: Response,) {
44
- if (this.keycloak == null) return false;
45
- // return await this.keycloak.protect('realm:user')(request, response, () => true /*next*/)
46
- return await this.keycloak.protect()(request, response, () => true /*next*/);
47
- }
48
-
49
-
50
- public async authenticate(user: WebUser, request: Request, response: Response) // BC signature
51
- {
52
-
53
- let identity = null;
54
- let token = null;
55
-
56
- let autHeader = this.getHeaderByKey(request.headers, this.header)
57
- if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
58
- return null;
59
- }
60
-
61
- token = JsonWebToken.decode(autHeader[1], {complete: true})
62
- if (!token) {
63
- BaseChyz.warning("Your request was made with invalid or expired JSON Web Token.");
64
- this.fail(response);
65
- }
66
-
67
- if (token !== null) {
68
- identity = await this.KeyCloakCheck(autHeader[1], request, response)
69
- BaseChyz.debug("KeyCloakCheck Result:", identity)
70
- }
71
-
72
- if (identity == null || identity == false) this.fail(response)
73
-
74
- return identity;
75
-
76
- /* let autHeader = this.getHeaderByKey(request.headers, this.header)
77
- if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
78
- return null;
79
- }
80
-
81
- BaseChyz.debug("JSON Web Token.",autHeader);
82
- let identity = null;
83
- let token = null;
84
-
85
- token = JsonWebToken.decode(autHeader[1], {complete: true})
86
- if (!token) {
87
- BaseChyz.warning("Your request was made with invalid or expired JSON Web Token.");
88
- this.fail(response);
89
- }
90
-
91
- if (token !== null) {
92
- if (this.auth != null) {
93
- identity = await this.auth(autHeader[1])
94
- } else {
95
- identity = await user.loginByAccessToken(autHeader[1], "JwtHttpBearerAuth")
96
- }
97
- }
98
-
99
- if (identity == null) this.fail(response)
100
-
101
-
102
-
103
- return identity;*/
104
- }
105
-
106
-
107
- /**
108
- * @throws UnauthorizedHttpException
109
- */
110
- public fail(response: Response): void {
111
- // this.challenge(response)
112
- // this.handleFailure(response);
113
- }
114
-
115
- }
@@ -1,4 +0,0 @@
1
- export * from "./JwtHttpBearerAuth"
2
- export * from "./HttpBearerAuth"
3
- export * from "./HttpHeaderAuth"
4
- export * from "./HttpBasicAuth"
package/filters/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./AccessControl"
2
- export * from "./AccessRule"
package/index.ts DELETED
@@ -1,16 +0,0 @@
1
- export {Request, Response, NextFunction} from "express";
2
- export * from "./base";
3
- export * from "./filters";
4
- export * from "./filters/auth";
5
- export * from "./decorator";
6
- export * from "./requiments/Utils";
7
- export {RouteDefinition} from "./model/RouteDefinition";
8
- export {WebUser} from "./web/WebUser";
9
-
10
- import BaseChyz from "./BaseChyz";
11
- export {BaseChyz}
12
- /**
13
- *
14
- */
15
- const Chyz = new BaseChyz();
16
- export default Chyz;
@@ -1,18 +0,0 @@
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
- export interface RouteDefinition {
9
- //id
10
- id:string;
11
- // Path to our route
12
- path: string;
13
- // HTTP Request method (get, post, ...)
14
- requestMethod: 'get' | 'post' | 'delete' | 'options' | 'put';
15
- // Method name within our class responsible for this route
16
- methodName: string;
17
- }
18
-