chyz 2.0.1-rc.36 → 2.0.1-rc.37
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/dist/BaseChyz.d.ts +74 -0
- package/dist/BaseChyz.d.ts.map +1 -0
- package/dist/BaseChyz.js +586 -0
- package/dist/base/ActionFilter.d.ts +32 -0
- package/dist/base/ActionFilter.d.ts.map +1 -0
- package/dist/base/ActionFilter.js +90 -0
- package/dist/base/BadRequestHttpException.d.ts +6 -0
- package/dist/base/BadRequestHttpException.d.ts.map +1 -0
- package/dist/base/BadRequestHttpException.js +17 -0
- package/dist/base/BaseError.d.ts +44 -0
- package/dist/base/BaseError.d.ts.map +1 -0
- package/{base/BaseError.ts → dist/base/BaseError.js} +18 -26
- package/dist/base/Behavior.d.ts +4 -0
- package/dist/base/Behavior.d.ts.map +1 -0
- package/dist/base/Behavior.js +7 -0
- package/dist/base/CBaseObject.d.ts +5 -0
- package/dist/base/CBaseObject.d.ts.map +1 -0
- package/dist/base/CBaseObject.js +16 -0
- package/dist/base/CEvents.d.ts +13 -0
- package/dist/base/CEvents.d.ts.map +1 -0
- package/dist/base/CEvents.js +24 -0
- package/dist/base/CRequest.d.ts +2 -0
- package/dist/base/CRequest.d.ts.map +1 -0
- package/{base/CRequest.ts → dist/base/CRequest.js} +2 -6
- package/dist/base/CWebController.d.ts +44 -0
- package/dist/base/CWebController.d.ts.map +1 -0
- package/dist/base/CWebController.js +81 -0
- package/dist/base/Component.d.ts +21 -0
- package/dist/base/Component.d.ts.map +1 -0
- package/dist/base/Component.js +57 -0
- package/dist/base/Configurable.d.ts +3 -0
- package/dist/base/Configurable.d.ts.map +1 -0
- package/{requiments/Glob.ts → dist/base/Configurable.js} +2 -3
- package/dist/base/DataErrorDbException.d.ts +6 -0
- package/dist/base/DataErrorDbException.d.ts.map +1 -0
- package/dist/base/DataErrorDbException.js +17 -0
- package/dist/base/DbConnection.d.ts +13 -0
- package/dist/base/DbConnection.d.ts.map +1 -0
- package/dist/base/DbConnection.js +53 -0
- package/dist/base/ForbiddenHttpException.d.ts +5 -0
- package/dist/base/ForbiddenHttpException.d.ts.map +1 -0
- package/dist/base/ForbiddenHttpException.js +16 -0
- package/dist/base/InvalidArgumentException.d.ts +6 -0
- package/dist/base/InvalidArgumentException.d.ts.map +1 -0
- package/dist/base/InvalidArgumentException.js +17 -0
- package/dist/base/InvalidConfigException.d.ts +6 -0
- package/dist/base/InvalidConfigException.d.ts.map +1 -0
- package/dist/base/InvalidConfigException.js +17 -0
- package/dist/base/Logs.d.ts +22 -0
- package/dist/base/Logs.d.ts.map +1 -0
- package/{base/Logs.ts → dist/base/Logs.js} +24 -41
- package/dist/base/Model.d.ts +302 -0
- package/dist/base/Model.d.ts.map +1 -0
- package/{base/Model.ts → dist/base/Model.js} +158 -225
- package/dist/base/ModelManager.d.ts +2 -0
- package/dist/base/ModelManager.d.ts.map +1 -0
- package/{base/ModelManager.ts → dist/base/ModelManager.js} +7 -7
- package/dist/base/NotFoundHttpException.d.ts +6 -0
- package/dist/base/NotFoundHttpException.d.ts.map +1 -0
- package/dist/base/NotFoundHttpException.js +17 -0
- package/dist/base/RestClient.d.ts +7 -0
- package/dist/base/RestClient.d.ts.map +1 -0
- package/dist/base/RestClient.js +25 -0
- package/dist/base/UnauthorizedHttpException.d.ts +6 -0
- package/dist/base/UnauthorizedHttpException.d.ts.map +1 -0
- package/dist/base/UnauthorizedHttpException.js +17 -0
- package/dist/base/ValidationHttpException.d.ts +6 -0
- package/dist/base/ValidationHttpException.d.ts.map +1 -0
- package/dist/base/ValidationHttpException.js +17 -0
- package/dist/base/db/Exception.d.ts +7 -0
- package/dist/base/db/Exception.d.ts.map +1 -0
- package/dist/base/db/Exception.js +15 -0
- package/dist/base/index.d.ts +20 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +41 -0
- package/dist/decorator/Middleware.d.ts +4 -0
- package/dist/decorator/Middleware.d.ts.map +1 -0
- package/dist/decorator/Middleware.js +10 -0
- package/dist/decorator/controller.d.ts +3 -0
- package/dist/decorator/controller.d.ts.map +1 -0
- package/{decorator/controller.ts → dist/decorator/controller.js} +9 -7
- package/dist/decorator/delete.d.ts +3 -0
- package/dist/decorator/delete.d.ts.map +1 -0
- package/{decorator/delete.ts → dist/decorator/delete.js} +9 -9
- package/dist/decorator/enums/ControllerDecoratorParams.d.ts +6 -0
- package/dist/decorator/enums/ControllerDecoratorParams.d.ts.map +1 -0
- package/dist/decorator/enums/ControllerDecoratorParams.js +9 -0
- package/dist/decorator/get.d.ts +3 -0
- package/dist/decorator/get.d.ts.map +1 -0
- package/{decorator/get.ts → dist/decorator/get.js} +10 -11
- package/dist/decorator/index.d.ts +6 -0
- package/dist/decorator/index.d.ts.map +1 -0
- package/dist/decorator/index.js +13 -0
- package/dist/decorator/post.d.ts +3 -0
- package/dist/decorator/post.d.ts.map +1 -0
- package/{decorator/post.ts → dist/decorator/post.js} +10 -10
- package/dist/decorator/put.d.ts +3 -0
- package/dist/decorator/put.d.ts.map +1 -0
- package/{decorator/put.ts → dist/decorator/put.js} +9 -9
- package/dist/filters/AccessControl.d.ts +12 -0
- package/dist/filters/AccessControl.d.ts.map +1 -0
- package/dist/filters/AccessControl.js +83 -0
- package/dist/filters/AccessRule.d.ts +83 -0
- package/dist/filters/AccessRule.d.ts.map +1 -0
- package/dist/filters/AccessRule.js +136 -0
- package/{filters/auth/AuthInterface.ts → dist/filters/auth/AuthInterface.d.ts} +7 -15
- package/dist/filters/auth/AuthInterface.d.ts.map +1 -0
- package/dist/filters/auth/AuthInterface.js +2 -0
- package/dist/filters/auth/AuthMethod.d.ts +38 -0
- package/dist/filters/auth/AuthMethod.d.ts.map +1 -0
- package/dist/filters/auth/AuthMethod.js +82 -0
- package/dist/filters/auth/HttpBasicAuth.d.ts +24 -0
- package/dist/filters/auth/HttpBasicAuth.d.ts.map +1 -0
- package/dist/filters/auth/HttpBasicAuth.js +79 -0
- package/dist/filters/auth/HttpBearerAuth.d.ts +18 -0
- package/dist/filters/auth/HttpBearerAuth.d.ts.map +1 -0
- package/dist/filters/auth/HttpBearerAuth.js +33 -0
- package/dist/filters/auth/HttpHeaderAuth.d.ts +19 -0
- package/dist/filters/auth/HttpHeaderAuth.d.ts.map +1 -0
- package/dist/filters/auth/HttpHeaderAuth.js +64 -0
- package/dist/filters/auth/JwtHttpBearerAuth.d.ts +21 -0
- package/dist/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -0
- package/dist/filters/auth/JwtHttpBearerAuth.js +88 -0
- package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts +23 -0
- package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts.map +1 -0
- package/dist/filters/auth/KeyCloakHttpBearerAuth.js +116 -0
- package/dist/filters/auth/index.d.ts +5 -0
- package/dist/filters/auth/index.d.ts.map +1 -0
- package/dist/filters/auth/index.js +11 -0
- package/dist/filters/index.d.ts +3 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/index.js +7 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/log/log/config/log4js.json +55 -0
- package/dist/model/RouteDefinition.d.ts +7 -0
- package/dist/model/RouteDefinition.d.ts.map +1 -0
- package/{base/Configurable.ts → dist/model/RouteDefinition.js} +2 -4
- package/dist/package.json +63 -0
- package/dist/rbac/AuthAssignment.d.ts +19 -0
- package/dist/rbac/AuthAssignment.d.ts.map +1 -0
- package/dist/rbac/AuthAssignment.js +44 -0
- package/dist/rbac/AuthItem.d.ts +27 -0
- package/dist/rbac/AuthItem.d.ts.map +1 -0
- package/{rbac/AuthItem.ts → dist/rbac/AuthItem.js} +16 -22
- package/dist/rbac/AuthItemChild.d.ts +19 -0
- package/dist/rbac/AuthItemChild.d.ts.map +1 -0
- package/{rbac/AuthItemChild.ts → dist/rbac/AuthItemChild.js} +14 -21
- package/dist/rbac/AuthManager.d.ts +112 -0
- package/dist/rbac/AuthManager.d.ts.map +1 -0
- package/dist/rbac/AuthManager.js +356 -0
- package/dist/rbac/index.d.ts +5 -0
- package/dist/rbac/index.d.ts.map +1 -0
- package/dist/rbac/index.js +28 -0
- package/dist/requiments/Glob.d.ts +3 -0
- package/dist/requiments/Glob.d.ts.map +1 -0
- package/dist/requiments/Glob.js +10 -0
- package/dist/requiments/ReflectUtil.d.ts +1 -0
- package/dist/requiments/ReflectUtil.d.ts.map +1 -0
- package/{requiments/ReflectUtil.ts → dist/requiments/ReflectUtil.js} +4 -6
- package/dist/requiments/Utils.d.ts +2 -0
- package/dist/requiments/Utils.d.ts.map +1 -0
- package/{requiments/Utils.ts → dist/requiments/Utils.js} +34 -40
- package/dist/validators/BooleanValidator.d.ts +1 -0
- package/dist/validators/BooleanValidator.d.ts.map +1 -0
- package/dist/validators/BooleanValidator.js +1 -0
- package/dist/validators/CompareValidator.d.ts +1 -0
- package/dist/validators/CompareValidator.d.ts.map +1 -0
- package/dist/validators/CompareValidator.js +1 -0
- package/dist/validators/DateValidator.d.ts +1 -0
- package/dist/validators/DateValidator.d.ts.map +1 -0
- package/dist/validators/DateValidator.js +1 -0
- package/dist/validators/EmailValidator.d.ts +1 -0
- package/dist/validators/EmailValidator.d.ts.map +1 -0
- package/dist/validators/EmailValidator.js +1 -0
- package/dist/validators/Validator.d.ts +18 -0
- package/dist/validators/Validator.d.ts.map +1 -0
- package/dist/validators/Validator.js +27 -0
- package/{web/IdentityInterface.ts → dist/web/IdentityInterface.d.ts} +2 -15
- package/dist/web/IdentityInterface.d.ts.map +1 -0
- package/dist/web/IdentityInterface.js +8 -0
- package/dist/web/WebUser.d.ts +72 -0
- package/dist/web/WebUser.d.ts.map +1 -0
- package/dist/web/WebUser.js +165 -0
- package/package.json +16 -56
- package/BaseChyz.ts +0 -623
- package/base/ActionFilter.ts +0 -88
- package/base/BadRequestHttpException.ts +0 -14
- package/base/Behavior.ts +0 -6
- package/base/CBaseObject.ts +0 -17
- package/base/CEvents.ts +0 -24
- package/base/CWebController.ts +0 -90
- package/base/Component.ts +0 -66
- package/base/DataErrorDbException.ts +0 -16
- package/base/DbConnection.ts +0 -55
- package/base/ForbiddenHttpException.ts +0 -15
- package/base/InvalidArgumentException.ts +0 -16
- package/base/InvalidConfigException.ts +0 -16
- package/base/NotFoundHttpException.ts +0 -14
- package/base/RestClient.ts +0 -26
- package/base/UnauthorizedHttpException.ts +0 -17
- package/base/ValidationHttpException.ts +0 -14
- package/base/db/Exception.ts +0 -14
- package/base/index.ts +0 -19
- package/decorator/Middleware.ts +0 -9
- package/decorator/enums/ControllerDecoratorParams.ts +0 -5
- package/decorator/index.ts +0 -5
- package/filters/AccessControl.ts +0 -74
- package/filters/AccessRule.ts +0 -182
- package/filters/auth/AuthMethod.ts +0 -100
- package/filters/auth/HttpBasicAuth.ts +0 -79
- package/filters/auth/HttpBearerAuth.ts +0 -34
- package/filters/auth/HttpHeaderAuth.ts +0 -61
- package/filters/auth/JwtHttpBearerAuth.ts +0 -83
- package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -114
- package/filters/auth/index.ts +0 -4
- package/filters/index.ts +0 -2
- package/index.ts +0 -80
- package/model/RouteDefinition.ts +0 -18
- package/rbac/AuthAssignment.ts +0 -50
- package/rbac/AuthManager.ts +0 -399
- package/rbac/index.ts +0 -12
- 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 +0 -27
- package/web/WebUser.ts +0 -187
- /package/{README.md → dist/README.md} +0 -0
- /package/{log → dist/log}/config/log4js.json +0 -0
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.id : 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
|
-
}
|
|
File without changes
|
|
File without changes
|