chyz 1.0.13-rc.19 → 1.0.13-rc.4

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 (211) hide show
  1. package/{dist/BaseChyz.js → BaseChyz.js} +8 -46
  2. package/BaseChyz.js.map +1 -0
  3. package/{dist/Chyz.js → Chyz.js} +0 -0
  4. package/{dist/Chyz.js.map → Chyz.js.map} +0 -0
  5. package/README.md +16 -267
  6. package/{dist/base → base}/ActionFilter.js +1 -1
  7. package/{dist/base → base}/ActionFilter.js.map +1 -1
  8. package/{dist/base → base}/BaseError.js +1 -5
  9. package/base/BaseError.js.map +1 -0
  10. package/{dist/base → base}/BaseObject.js +0 -0
  11. package/{dist/base → base}/BaseObject.js.map +0 -0
  12. package/{dist/base → base}/Behavior.js +0 -0
  13. package/{dist/base → base}/Behavior.js.map +0 -0
  14. package/{dist/base → base}/Component.js +0 -0
  15. package/{dist/base → base}/Component.js.map +0 -0
  16. package/{dist/base → base}/Configurable.js +0 -0
  17. package/{dist/base → base}/Configurable.js.map +0 -0
  18. package/{dist/base → base}/Controller.js +0 -0
  19. package/{dist/base → base}/Controller.js.map +0 -0
  20. package/{dist/base → base}/DataErrorDbException.js +0 -0
  21. package/{dist/base → base}/DataErrorDbException.js.map +0 -0
  22. package/{dist/base → base}/DbConnection.js +0 -0
  23. package/{dist/base → base}/DbConnection.js.map +0 -0
  24. package/{dist/base → base}/ForbiddenHttpException.js +0 -0
  25. package/{dist/base → base}/ForbiddenHttpException.js.map +0 -0
  26. package/{dist/base → base}/InvalidConfigException.js +0 -0
  27. package/{dist/base → base}/InvalidConfigException.js.map +0 -0
  28. package/{dist/base → base}/Model.js +30 -37
  29. package/base/Model.js.map +1 -0
  30. package/{dist/base → base}/NotFoundHttpException.js +0 -0
  31. package/{dist/base → base}/NotFoundHttpException.js.map +0 -0
  32. package/{dist/base → base}/RestClient.js +4 -4
  33. package/base/RestClient.js.map +1 -0
  34. package/{dist/base → base}/UnauthorizedHttpException.js +0 -0
  35. package/{dist/base → base}/UnauthorizedHttpException.js.map +0 -0
  36. package/{dist/base → base}/ValidationHttpException.js +1 -1
  37. package/{dist/base → base}/ValidationHttpException.js.map +0 -0
  38. package/{dist/base → base}/db/Exception.js +0 -0
  39. package/{dist/base → base}/db/Exception.js.map +0 -0
  40. package/{dist/base → base}/index.js +0 -2
  41. package/{dist/base → base}/index.js.map +1 -1
  42. package/{dist/decorator → decorator}/Middleware.js +0 -0
  43. package/{dist/decorator → decorator}/Middleware.js.map +0 -0
  44. package/{dist/decorator → decorator}/controller.js +0 -0
  45. package/{dist/decorator → decorator}/controller.js.map +0 -0
  46. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js +0 -0
  47. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js.map +0 -0
  48. package/{dist/decorator → decorator}/get.js +0 -0
  49. package/{dist/decorator → decorator}/get.js.map +0 -0
  50. package/{dist/decorator → decorator}/index.js +0 -0
  51. package/{dist/decorator → decorator}/index.js.map +0 -0
  52. package/{dist/decorator → decorator}/post.js +0 -0
  53. package/{dist/decorator → decorator}/post.js.map +0 -0
  54. package/{dist/filters → filters}/AccessControl.js +3 -15
  55. package/filters/AccessControl.js.map +1 -0
  56. package/filters/AccessRule.js +79 -0
  57. package/filters/AccessRule.js.map +1 -0
  58. package/{dist/filters → filters}/auth/AuthInterface.js +0 -0
  59. package/{dist/filters → filters}/auth/AuthInterface.js.map +0 -0
  60. package/{dist/filters → filters}/auth/AuthMethod.js +0 -0
  61. package/{dist/filters → filters}/auth/AuthMethod.js.map +0 -0
  62. package/{requiments/Glob.ts → filters/auth/HttpBasicAuth.js} +2 -3
  63. package/filters/auth/HttpBasicAuth.js.map +1 -0
  64. package/{dist/filters → filters}/auth/HttpBearerAuth.js +0 -0
  65. package/{dist/filters → filters}/auth/HttpBearerAuth.js.map +0 -0
  66. package/{dist/filters → filters}/auth/HttpHeaderAuth.js +0 -0
  67. package/{dist/filters → filters}/auth/HttpHeaderAuth.js.map +0 -0
  68. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js +1 -1
  69. package/filters/auth/JwtHttpBearerAuth.js.map +1 -0
  70. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
  71. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
  72. package/{dist/filters → filters}/auth/index.js +0 -1
  73. package/{dist/filters → filters}/auth/index.js.map +1 -1
  74. package/{dist/filters → filters}/index.js +0 -0
  75. package/{dist/filters → filters}/index.js.map +0 -0
  76. package/{dist/index.js → index.js} +0 -0
  77. package/{dist/index.js.map → index.js.map} +0 -0
  78. package/{dist/model → model}/RouteDefinition.js +0 -0
  79. package/{dist/model → model}/RouteDefinition.js.map +0 -0
  80. package/package.json +7 -6
  81. package/{dist/requiments → requiments}/Glob.js +0 -0
  82. package/{dist/requiments → requiments}/Glob.js.map +0 -0
  83. package/{dist/requiments → requiments}/ReflectUtil.js +0 -0
  84. package/{dist/requiments → requiments}/ReflectUtil.js.map +0 -0
  85. package/{dist/requiments → requiments}/Utils.js +0 -0
  86. package/{dist/requiments → requiments}/Utils.js.map +0 -0
  87. package/{dist/validators → validators}/BooleanValidator.js +0 -0
  88. package/{dist/validators → validators}/BooleanValidator.js.map +0 -0
  89. package/{dist/validators → validators}/CompareValidator.js +0 -0
  90. package/{dist/validators → validators}/CompareValidator.js.map +0 -0
  91. package/{dist/validators → validators}/DateValidator.js +0 -0
  92. package/{dist/validators → validators}/DateValidator.js.map +0 -0
  93. package/{dist/validators → validators}/EmailValidator.js +0 -0
  94. package/{dist/validators → validators}/EmailValidator.js.map +0 -0
  95. package/{dist/validators → validators}/Validator.js +0 -0
  96. package/{dist/validators → validators}/Validator.js.map +0 -0
  97. package/{dist/web → web}/IdentityInterface.js +0 -0
  98. package/{dist/web → web}/IdentityInterface.js.map +0 -0
  99. package/web/WebUser.js +88 -0
  100. package/web/WebUser.js.map +1 -0
  101. package/BaseChyz.ts +0 -399
  102. package/Chyz.ts +0 -11
  103. package/Doc/Moel kullanma.md +0 -13
  104. package/Examples/Controllers/ApiController.ts +0 -140
  105. package/Examples/Controllers/BasicApiController.ts +0 -121
  106. package/Examples/Controllers/KeyCloakController.ts +0 -100
  107. package/Examples/Controllers/PublicController.ts +0 -42
  108. package/Examples/Controllers/SiteController.ts +0 -149
  109. package/Examples/Models/AuthAssignment.ts +0 -50
  110. package/Examples/Models/AuthItem.ts +0 -59
  111. package/Examples/Models/AuthItemChild.ts +0 -49
  112. package/Examples/Models/Categories.ts +0 -47
  113. package/Examples/Models/Customer.ts +0 -115
  114. package/Examples/Models/KeycloakUser.ts +0 -70
  115. package/Examples/Models/Order.ts +0 -64
  116. package/Examples/Models/OrderItem.ts +0 -27
  117. package/Examples/Models/ProductModels.ts +0 -49
  118. package/Examples/Models/ProductToCategories.ts +0 -46
  119. package/Examples/Models/Products.ts +0 -50
  120. package/Examples/Models/Stocks.ts +0 -60
  121. package/Examples/Models/User.ts +0 -107
  122. package/Examples/Models/UserPermission.ts +0 -37
  123. package/Examples/Models/index.ts +0 -19
  124. package/Examples/index-keycloack.ts +0 -78
  125. package/Examples/index.ts +0 -45
  126. package/Examples/keycloak.json +0 -7
  127. package/Examples/log/access.log +0 -0
  128. package/Examples/log/app.log +0 -10379
  129. package/Examples/log/errors.log +0 -1984
  130. package/Examples/package.json +0 -46
  131. package/Examples/tsconfig.json +0 -21
  132. package/base/ActionFilter.ts +0 -71
  133. package/base/BaseError.ts +0 -28
  134. package/base/BaseObject.ts +0 -19
  135. package/base/Behavior.ts +0 -6
  136. package/base/Component.ts +0 -66
  137. package/base/Configurable.ts +0 -10
  138. package/base/Controller.ts +0 -84
  139. package/base/DataErrorDbException.ts +0 -16
  140. package/base/DbConnection.ts +0 -51
  141. package/base/ForbiddenHttpException.ts +0 -15
  142. package/base/InvalidArgumentException.ts +0 -16
  143. package/base/InvalidConfigException.ts +0 -16
  144. package/base/Model.ts +0 -363
  145. package/base/ModelManager.ts +0 -19
  146. package/base/NotFoundHttpException.ts +0 -14
  147. package/base/RestClient.ts +0 -28
  148. package/base/UnauthorizedHttpException.ts +0 -17
  149. package/base/ValidationHttpException.ts +0 -14
  150. package/base/db/Exception.ts +0 -14
  151. package/base/index.ts +0 -18
  152. package/decorator/Middleware.ts +0 -9
  153. package/decorator/controller.ts +0 -22
  154. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  155. package/decorator/get.ts +0 -37
  156. package/decorator/index.ts +0 -3
  157. package/decorator/post.ts +0 -36
  158. package/dist/BaseChyz.js.map +0 -1
  159. package/dist/base/BaseError.js.map +0 -1
  160. package/dist/base/InvalidArgumentException.js +0 -18
  161. package/dist/base/InvalidArgumentException.js.map +0 -1
  162. package/dist/base/Model.js.map +0 -1
  163. package/dist/base/ModelManager.js +0 -9
  164. package/dist/base/ModelManager.js.map +0 -1
  165. package/dist/base/RestClient.js.map +0 -1
  166. package/dist/filters/AccessControl.js.map +0 -1
  167. package/dist/filters/AccessRule.js +0 -140
  168. package/dist/filters/AccessRule.js.map +0 -1
  169. package/dist/filters/auth/HttpBasicAuth.js +0 -73
  170. package/dist/filters/auth/HttpBasicAuth.js.map +0 -1
  171. package/dist/filters/auth/JwtHttpBearerAuth.js.map +0 -1
  172. package/dist/log/config/log4js.json +0 -55
  173. package/dist/package.json +0 -55
  174. package/dist/rbac/AuthAssignment.js +0 -45
  175. package/dist/rbac/AuthAssignment.js.map +0 -1
  176. package/dist/rbac/AuthItem.js +0 -52
  177. package/dist/rbac/AuthItem.js.map +0 -1
  178. package/dist/rbac/AuthItemChild.js +0 -44
  179. package/dist/rbac/AuthItemChild.js.map +0 -1
  180. package/dist/rbac/AuthManager.js +0 -359
  181. package/dist/rbac/AuthManager.js.map +0 -1
  182. package/dist/web/WebUser.js +0 -166
  183. package/dist/web/WebUser.js.map +0 -1
  184. package/filters/AccessControl.ts +0 -77
  185. package/filters/AccessRule.ts +0 -182
  186. package/filters/auth/AuthInterface.ts +0 -34
  187. package/filters/auth/AuthMethod.ts +0 -88
  188. package/filters/auth/HttpBasicAuth.ts +0 -75
  189. package/filters/auth/HttpBearerAuth.ts +0 -31
  190. package/filters/auth/HttpHeaderAuth.ts +0 -53
  191. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  192. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  193. package/filters/auth/index.ts +0 -4
  194. package/filters/index.ts +0 -2
  195. package/index.ts +0 -14
  196. package/model/RouteDefinition.ts +0 -18
  197. package/package-lock.json +0 -5259
  198. package/rbac/AuthAssignment.ts +0 -50
  199. package/rbac/AuthItem.ts +0 -57
  200. package/rbac/AuthItemChild.ts +0 -50
  201. package/rbac/AuthManager.ts +0 -398
  202. package/requiments/ReflectUtil.ts +0 -26
  203. package/requiments/Utils.ts +0 -57
  204. package/tsconfig.json +0 -18
  205. package/validators/BooleanValidator.ts +0 -0
  206. package/validators/CompareValidator.ts +0 -0
  207. package/validators/DateValidator.ts +0 -0
  208. package/validators/EmailValidator.ts +0 -0
  209. package/validators/Validator.ts +0 -27
  210. package/web/IdentityInterface.ts +0 -68
  211. package/web/WebUser.ts +0 -187
@@ -1,68 +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 IdentityInterface {
9
- /**
10
- * Finds an identity by the given ID.
11
- * @param string|int $id the ID to be looked for
12
- * @return IdentityInterface|null the identity object that matches the given ID.
13
- * Null should be returned if such an identity cannot be found
14
- * or the identity is not in an active state (disabled, deleted, etc.)
15
- */
16
- findIdentity(id: number): any
17
-
18
- /**
19
- * Finds an identity by the given token.
20
- * For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`.
21
- * @return IdentityInterface|null the identity object that matches the given token.
22
- * Null should be returned if such an identity cannot be found
23
- * or the identity is not in an active state (disabled, deleted, etc.)
24
- * @param token
25
- * @param type
26
- */
27
- findIdentityByAccessToken(token: any, type: string): any;
28
-
29
- /**
30
- * Returns an ID that can uniquely identify a user identity.
31
- * @return string|int an ID that uniquely identifies a user identity.
32
- */
33
- getId(): number;
34
-
35
- /**
36
- * Returns a key that can be used to check the validity of a given identity ID.
37
- *
38
- * The key should be unique for each individual user, and should be persistent
39
- * so that it can be used to check the validity of the user identity.
40
- *
41
- * The space of such keys should be big enough to defeat potential identity attacks.
42
- *
43
- * The returned key is used to validate session and auto-login (if [[User::enableAutoLogin]] is enabled).
44
- *
45
- * Make sure to invalidate earlier issued authKeys when you implement force user logout, password change and
46
- * other scenarios, that require forceful access revocation for old sessions.
47
- *
48
- * @return string|null a key that is used to check the validity of a given identity ID.
49
- * @see validateAuthKey()
50
- */
51
- getAuthKey(): string;
52
-
53
- /**
54
- * Validates the given auth key.
55
- *
56
- * @param string $authKey the given auth key
57
- * @return bool|null whether the given auth key is valid.
58
- * @see getAuthKey()
59
- */
60
- validateAuthKey(authKey: string): (boolean | null);
61
-
62
-
63
- /**
64
- *
65
- */
66
- can(permissionName:string, params: any[] , allowCaching: boolean ): (boolean | null);
67
-
68
- }
package/web/WebUser.ts DELETED
@@ -1,187 +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 {Component} from "../base/Component";
9
- import {ForbiddenHttpException} from "../base/ForbiddenHttpException";
10
- import {InvalidConfigException} from "../base/InvalidConfigException";
11
- import {IdentityInterface} from "./IdentityInterface";
12
- import Utils from "../requiments/Utils";
13
- import {AuthManager} from "../rbac/AuthManager";
14
-
15
- export class WebUser extends Component {
16
-
17
- /**
18
- * @var string the class name of the [[identity]] object.
19
- */
20
- public identityClass: any;
21
- private _identity: any;
22
- /**
23
- * @var CheckAccessInterface|string|array The access checker object to use for checking access or the application
24
- * component ID of the access checker.
25
- * If not set the application auth manager will be used.
26
- * @since 2.0.9
27
- */
28
- public accessChecker: any = null;
29
-
30
-
31
- get identity() {
32
- return this._identity;
33
- }
34
-
35
- set identity(value) {
36
- this._identity = value;
37
- }
38
-
39
- public init() {
40
- super.init();
41
-
42
- if (this.identityClass === null) {
43
- throw new InvalidConfigException('User::identityClass must be set.');
44
- }
45
-
46
-
47
- this.identityClass = new this.identityClass();
48
-
49
- }
50
-
51
- public getIsGuest() {
52
- return this.getIdentity() === null;
53
- }
54
-
55
- public getIdentity(autoRenew = true) {
56
- return this._identity;
57
- }
58
-
59
- public loginRequired() {
60
-
61
- throw new ForbiddenHttpException(BaseChyz.t('Login Required'));
62
- }
63
-
64
-
65
- /**
66
- * Regenerates CSRF token
67
- *
68
- * @since 2.0.14.2
69
- */
70
- protected regenerateCsrfToken() {
71
-
72
- }
73
-
74
- /**
75
- * Logs in a user by the given access token.
76
- * @param token
77
- * @param type
78
- */
79
- public async loginByAccessToken(token: any, type: any = null) {
80
-
81
- let $class = this.identityClass;
82
- if ($class.findIdentityByAccessToken) {
83
- this.identity = await $class.findIdentityByAccessToken(token, type)
84
- if (this.identity && this.login(this.identity)) {
85
- return this.identity;
86
- }
87
- } else {
88
- BaseChyz.error("WebUser::findIdentityByAccessToken undefined")
89
- }
90
- return null;
91
- }
92
-
93
- public login(identity: IdentityInterface, duration = 0): boolean {
94
-
95
- if (this.beforeLogin(identity, false, duration)) {
96
-
97
- }
98
- return !this.getIsGuest()
99
- }
100
-
101
- public beforeLogin(identity: any, cookieBased: boolean, duration: number) {
102
-
103
- return true;
104
- }
105
-
106
- public afterLogin() {
107
-
108
- }
109
-
110
- public getId() {
111
- let identity = this.getIdentity();
112
- return identity !== null ? identity.getId() : null;
113
- }
114
-
115
- /**
116
- * Checks if the user can perform the operation as specified by the given permission.
117
- *
118
- * Note that you must configure "authManager" application component in order to use this method.
119
- * Otherwise it will always return false.
120
- *
121
- * @param string $permissionName the name of the permission (e.g. "edit post") that needs access check.
122
- * @param array $params name-value pairs that would be passed to the rules associated
123
- * with the roles and permissions assigned to the user.
124
- * @param bool $allowCaching whether to allow caching the result of access check.
125
- * When this parameter is true (default), if the access check of an operation was performed
126
- * before, its result will be directly returned when calling this method to check the same
127
- * operation. If this parameter is false, this method will always call
128
- * [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this
129
- * caching is effective only within the same request and only works when `$params = []`.
130
- * @return bool whether the user can perform the operation as specified by the given permission.
131
- */
132
- // public function can($permissionName, $params = [], $allowCaching = true)
133
- // {
134
- // if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
135
- // return $this->_access[$permissionName];
136
- // }
137
- // if (($accessChecker = $this->getAccessChecker()) === null) {
138
- // return false;
139
- // }
140
- // $access = $accessChecker->checkAccess($this->getId(), $permissionName, $params);
141
- // if ($allowCaching && empty($params)) {
142
- // $this->_access[$permissionName] = $access;
143
- // }
144
- //
145
- // return $access;
146
- // }
147
-
148
- public async can(permissionName: string, params = [], allowCaching = true) {
149
-
150
- let access;
151
- let accessChecker: AuthManager;
152
- if ((accessChecker = this.getAccessChecker()) == null)
153
- return false;
154
-
155
-
156
- access = await accessChecker.checkAccess(this.getId(), permissionName, params);
157
-
158
- if (allowCaching && Utils.isEmpty(params)) {
159
- // this._access[$permissionName] = $access;
160
- }
161
-
162
- return access;
163
-
164
- }
165
-
166
- /**
167
- * Returns auth manager associated with the user component.
168
- *
169
- * By default this is the `authManager` application component.
170
- * You may override this method to return a different auth manager instance if needed.
171
- * @return \yii\rbac\ManagerInterface
172
- * @since 2.0.6
173
- */
174
- protected getAuthManager(): AuthManager {
175
- return BaseChyz.getComponent('authManager');
176
- }
177
-
178
- /**
179
- * Returns the access checker used for checking access.
180
- * @return CheckAccessInterface
181
- */
182
- protected getAccessChecker():AuthManager {
183
- return this.accessChecker !== null ? this.accessChecker : this.getAuthManager();
184
- }
185
-
186
-
187
- }