@elementspanel/epanel-plugin-auth 0.0.0-stage → 1.0.0
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/LICENSE +201 -0
- package/README.md +4 -2
- package/daemon/backend/index.cjs +301 -0
- package/daemon/plugin.json +8 -0
- package/package.json +39 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 MCSManager
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @elementspanel/epanel-plugin-auth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Owns the daemon's identity check: the top-level middleware that gates every protocol event, the key verification the panel authenticates with, and the panel IP whitelist. Removing this plugin leaves the daemon answering to anyone who connects.
|
|
4
|
+
|
|
5
|
+
Available for: daemon.
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ "use strict";
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
4
|
+
|
|
5
|
+
/***/ "./plugins/auth/src/i18n/index.ts"
|
|
6
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13
|
+
exports.localeMessages = void 0;
|
|
14
|
+
const de_DE_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/de_DE.json"));
|
|
15
|
+
const en_US_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/en_US.json"));
|
|
16
|
+
const es_ES_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/es_ES.json"));
|
|
17
|
+
const fr_FR_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/fr_FR.json"));
|
|
18
|
+
const ja_JP_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/ja_JP.json"));
|
|
19
|
+
const ko_KR_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/ko_KR.json"));
|
|
20
|
+
const pt_BR_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/pt_BR.json"));
|
|
21
|
+
const ru_RU_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/ru_RU.json"));
|
|
22
|
+
const th_TH_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/th_TH.json"));
|
|
23
|
+
const tr_TR_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/tr_TR.json"));
|
|
24
|
+
const zh_CN_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/zh_CN.json"));
|
|
25
|
+
const zh_TW_json_1 = __importDefault(__webpack_require__("./plugins/auth/src/i18n/zh_TW.json"));
|
|
26
|
+
// The lines this plugin writes about who connected and who was turned away.
|
|
27
|
+
// Registered with the daemon's i18next instance at setup, so the shared
|
|
28
|
+
// foundational `plugins/i18n` catalogue carries nothing authentication-specific.
|
|
29
|
+
exports.localeMessages = {
|
|
30
|
+
de_de: de_DE_json_1.default,
|
|
31
|
+
en_us: en_US_json_1.default,
|
|
32
|
+
es_es: es_ES_json_1.default,
|
|
33
|
+
fr_fr: fr_FR_json_1.default,
|
|
34
|
+
ja_jp: ja_JP_json_1.default,
|
|
35
|
+
ko_kr: ko_KR_json_1.default,
|
|
36
|
+
pt_br: pt_BR_json_1.default,
|
|
37
|
+
ru_ru: ru_RU_json_1.default,
|
|
38
|
+
th_th: th_TH_json_1.default,
|
|
39
|
+
tr_tr: tr_TR_json_1.default,
|
|
40
|
+
zh_cn: zh_CN_json_1.default,
|
|
41
|
+
zh_tw: zh_TW_json_1.default
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/***/ },
|
|
46
|
+
|
|
47
|
+
/***/ "node:crypto"
|
|
48
|
+
(module) {
|
|
49
|
+
|
|
50
|
+
module.exports = require("node:crypto");
|
|
51
|
+
|
|
52
|
+
/***/ },
|
|
53
|
+
|
|
54
|
+
/***/ "./plugins/auth/src/i18n/de_DE.json"
|
|
55
|
+
(module) {
|
|
56
|
+
|
|
57
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Sitzung {{id}}({{address}}) Identitätsüberprüfung erfolgreich","TXT_CODE_auth_router.disconnect":"Die Sitzung {{id}}({{address}}) wurde aufgrund einer langen Zeitspanne ohne Identitätsüberprüfung getrennt.","TXT_CODE_auth_router.notAccess":"Sitzung {{id}}({{address}}) hat versucht, unbefugt auf {{event}} zuzugreifen und ist jetzt blockiert."}');
|
|
58
|
+
|
|
59
|
+
/***/ },
|
|
60
|
+
|
|
61
|
+
/***/ "./plugins/auth/src/i18n/en_US.json"
|
|
62
|
+
(module) {
|
|
63
|
+
|
|
64
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Session {{id}} ({{address}}) has successfully authenticated","TXT_CODE_auth_router.disconnect":"Session {{id}} ({{address}}) disconnected due to prolonged unauthentication","TXT_CODE_auth_router.notAccess":"Session {{id}} ({{address}}) attempted unauthorized access to {{event}} and has been blocked."}');
|
|
65
|
+
|
|
66
|
+
/***/ },
|
|
67
|
+
|
|
68
|
+
/***/ "./plugins/auth/src/i18n/es_ES.json"
|
|
69
|
+
(module) {
|
|
70
|
+
|
|
71
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Sesión {{id}}({{address}}) Verificación de identidad exitosa","TXT_CODE_auth_router.disconnect":"La sesión {{id}}({{address}}) se desconectó debido a un largo período de identidad no verificada.","TXT_CODE_auth_router.notAccess":"La sesión {{id}}({{address}}) intentó acceder no autorizado a {{event}} y ahora está bloqueada."}');
|
|
72
|
+
|
|
73
|
+
/***/ },
|
|
74
|
+
|
|
75
|
+
/***/ "./plugins/auth/src/i18n/fr_FR.json"
|
|
76
|
+
(module) {
|
|
77
|
+
|
|
78
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Session {{id}}({{address}}) Vérification d\'identité réussie","TXT_CODE_auth_router.disconnect":"La session {{id}}({{address}}) a été déconnectée en raison d\'une longue période d\'identité non vérifiée.","TXT_CODE_auth_router.notAccess":"La session {{id}}({{address}}) a tenté un accès non autorisé à {{event}} et est maintenant bloquée."}');
|
|
79
|
+
|
|
80
|
+
/***/ },
|
|
81
|
+
|
|
82
|
+
/***/ "./plugins/auth/src/i18n/ja_JP.json"
|
|
83
|
+
(module) {
|
|
84
|
+
|
|
85
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"セッション {{id}}({{address}}) の本人確認が成功しました","TXT_CODE_auth_router.disconnect":"セッション {{id}}({{address}}) は、長期間 ID が確認されなかったため切断されました。","TXT_CODE_auth_router.notAccess":"セッション {{id}}({{address}}) は {{event}} への不正アクセスを試みたため、現在ブロックされています。"}');
|
|
86
|
+
|
|
87
|
+
/***/ },
|
|
88
|
+
|
|
89
|
+
/***/ "./plugins/auth/src/i18n/ko_KR.json"
|
|
90
|
+
(module) {
|
|
91
|
+
|
|
92
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"세션 {{id}}({{address}}) 신원 확인 성공","TXT_CODE_auth_router.disconnect":"장기간 신원이 확인되지 않아 세션 {{id}}({{address}})의 연결이 끊어졌습니다.","TXT_CODE_auth_router.notAccess":"세션 {{id}}({{address}})이(가) {{event}}에 대한 무단 액세스를 시도하여 현재 차단되었습니다."}');
|
|
93
|
+
|
|
94
|
+
/***/ },
|
|
95
|
+
|
|
96
|
+
/***/ "./plugins/auth/src/i18n/pt_BR.json"
|
|
97
|
+
(module) {
|
|
98
|
+
|
|
99
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"A sessão {{id}} ({{address}}) foi autenticada com sucesso","TXT_CODE_auth_router.disconnect":"A sessão {{id}} ({{address}}) foi desconectada devido à não autenticação prolongada","TXT_CODE_auth_router.notAccess":"A sessão {{id}} ({{address}}) tentou um acesso não autorizado a {{event}} e foi bloqueada."}');
|
|
100
|
+
|
|
101
|
+
/***/ },
|
|
102
|
+
|
|
103
|
+
/***/ "./plugins/auth/src/i18n/ru_RU.json"
|
|
104
|
+
(module) {
|
|
105
|
+
|
|
106
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Сеанс {{id}} ({{address}}) успешно аутентифицирован","TXT_CODE_auth_router.disconnect":"Сеанс {{id}} ({{address}}) отключен из-за длительной неаутентификации","TXT_CODE_auth_router.notAccess":"Сеанс {{id}} ({{address}}) попытался совершить несанкционированный доступ к {{event}}, и был заблокирован."}');
|
|
107
|
+
|
|
108
|
+
/***/ },
|
|
109
|
+
|
|
110
|
+
/***/ "./plugins/auth/src/i18n/th_TH.json"
|
|
111
|
+
(module) {
|
|
112
|
+
|
|
113
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"เซสชัน {{id}} ({{address}}) ยืนยันตัวตนสำเร็จแล้ว","TXT_CODE_auth_router.disconnect":"เซสชัน {{id}} ({{address}}) ถูกตัดการเชื่อมต่อเนื่องจากไม่มีการยืนยันตัวตนเป็นเวลานาน","TXT_CODE_auth_router.notAccess":"เซสชัน {{id}} ({{address}}) พยายามเข้าถึง {{event}} โดยไม่ได้รับอนุญาตและถูกบล็อก"}');
|
|
114
|
+
|
|
115
|
+
/***/ },
|
|
116
|
+
|
|
117
|
+
/***/ "./plugins/auth/src/i18n/tr_TR.json"
|
|
118
|
+
(module) {
|
|
119
|
+
|
|
120
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"Oturum {{id}} ({{address}}) kimliği başarıyla doğrulandı","TXT_CODE_auth_router.disconnect":"Oturum {{id}} ({{address}}) uzun süreli kimlik doğrulaması nedeniyle bağlantısı kesildi","TXT_CODE_auth_router.notAccess":"Oturum {{id}} ({{address}}) {{event}}\'a yetkisiz erişim girişiminde bulundu ve engellendi."}');
|
|
121
|
+
|
|
122
|
+
/***/ },
|
|
123
|
+
|
|
124
|
+
/***/ "./plugins/auth/src/i18n/zh_CN.json"
|
|
125
|
+
(module) {
|
|
126
|
+
|
|
127
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"会话 {{id}}({{address}}) 验证身份成功","TXT_CODE_auth_router.disconnect":"会话 {{id}}({{address}}) 因长时间未验证身份而断开连接","TXT_CODE_auth_router.notAccess":"会话 {{id}}({{address}}) 试图无权限访问 {{event}} 现已阻止."}');
|
|
128
|
+
|
|
129
|
+
/***/ },
|
|
130
|
+
|
|
131
|
+
/***/ "./plugins/auth/src/i18n/zh_TW.json"
|
|
132
|
+
(module) {
|
|
133
|
+
|
|
134
|
+
module.exports = /*#__PURE__*/JSON.parse('{"TXT_CODE_auth_router.access":"會話 {{id}}({{address}}) 驗證身分成功","TXT_CODE_auth_router.disconnect":"會話 {{id}}({{address}}) 因長時間未驗證身分而中斷連線","TXT_CODE_auth_router.notAccess":"會話 {{id}}({{address}}) 試圖無權限存取 {{event}} 現已封鎖."}');
|
|
135
|
+
|
|
136
|
+
/***/ }
|
|
137
|
+
|
|
138
|
+
/******/ });
|
|
139
|
+
/************************************************************************/
|
|
140
|
+
/******/ // The module cache
|
|
141
|
+
/******/ var __webpack_module_cache__ = {};
|
|
142
|
+
/******/
|
|
143
|
+
/******/ // The require function
|
|
144
|
+
/******/ function __webpack_require__(moduleId) {
|
|
145
|
+
/******/ // Check if module is in cache
|
|
146
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
147
|
+
/******/ if (cachedModule !== undefined) {
|
|
148
|
+
/******/ return cachedModule.exports;
|
|
149
|
+
/******/ }
|
|
150
|
+
/******/ // Create a new module (and put it into the cache)
|
|
151
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
152
|
+
/******/ // no module.id needed
|
|
153
|
+
/******/ // no module.loaded needed
|
|
154
|
+
/******/ exports: {}
|
|
155
|
+
/******/ };
|
|
156
|
+
/******/
|
|
157
|
+
/******/ // Execute the module function
|
|
158
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
159
|
+
/******/
|
|
160
|
+
/******/ // Return the exports of the module
|
|
161
|
+
/******/ return module.exports;
|
|
162
|
+
/******/ }
|
|
163
|
+
/******/
|
|
164
|
+
/************************************************************************/
|
|
165
|
+
var __webpack_exports__ = {};
|
|
166
|
+
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
167
|
+
(() => {
|
|
168
|
+
var exports = __webpack_exports__;
|
|
169
|
+
|
|
170
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
171
|
+
exports.inject = void 0;
|
|
172
|
+
exports.apply = apply;
|
|
173
|
+
const node_crypto_1 = __webpack_require__("node:crypto");
|
|
174
|
+
const i18n_1 = __webpack_require__("./plugins/auth/src/i18n/index.ts");
|
|
175
|
+
// The daemon's identity check.
|
|
176
|
+
//
|
|
177
|
+
// Everything about deciding *who* may talk to this daemon lives here: the
|
|
178
|
+
// top-level protocol middleware that gates every event, the key comparison the
|
|
179
|
+
// panel authenticates with, the optional panel IP whitelist and the timeout that
|
|
180
|
+
// hangs up on a connection that never authenticates.
|
|
181
|
+
//
|
|
182
|
+
// The daemon core keeps no "is auth enabled" branch anywhere — it simply has no
|
|
183
|
+
// opinion on who is calling. Removing this plugin therefore leaves the daemon
|
|
184
|
+
// answering every event to anyone who can reach the port, which is the same trade
|
|
185
|
+
// the panel makes with `plugins/user`.
|
|
186
|
+
//
|
|
187
|
+
// The session type is this plugin's own; stream and upload passports are exposed
|
|
188
|
+
// by the runtime transfer service.
|
|
189
|
+
/** How long a connection may stay unauthenticated before it is hung up on. */
|
|
190
|
+
const AUTH_TIMEOUT = 6000;
|
|
191
|
+
/** What this plugin marks a session it has authenticated with. */
|
|
192
|
+
const LOGIN_BY_TOP_LEVEL = "TOP_LEVEL";
|
|
193
|
+
exports.inject = ["protocol", "i18n", "settings", "transfer"];
|
|
194
|
+
function apply(ctx) {
|
|
195
|
+
ctx.i18n.define(i18n_1.localeMessages);
|
|
196
|
+
const $t = ctx.i18n.$t;
|
|
197
|
+
const protocol = ctx.protocol;
|
|
198
|
+
// Temporary upload/download passports are part of authentication: they are
|
|
199
|
+
// issued only after the panel has authenticated and are consumed by the file
|
|
200
|
+
// and terminal plugins. Keeping this event here leaves the server plugin
|
|
201
|
+
// responsible only for transport.
|
|
202
|
+
const ONE_HOUR_TIME = 3600000;
|
|
203
|
+
protocol.on("passport/register", (routerCtx, data) => {
|
|
204
|
+
const start = Date.now();
|
|
205
|
+
const end = start + ONE_HOUR_TIME;
|
|
206
|
+
if (!data?.name || !data?.password) {
|
|
207
|
+
throw new Error($t("TXT_CODE_passport_router.registerErr"));
|
|
208
|
+
}
|
|
209
|
+
ctx.transfer.passports.registerMission(data.password, {
|
|
210
|
+
name: data.name,
|
|
211
|
+
parameter: { ...data.parameter, _taskOwner: data._taskOwner },
|
|
212
|
+
count: data.count,
|
|
213
|
+
start,
|
|
214
|
+
end
|
|
215
|
+
});
|
|
216
|
+
protocol.response(routerCtx, true);
|
|
217
|
+
});
|
|
218
|
+
const isAuthenticated = (routerCtx) => routerCtx.session.key === ctx.settings.config.key &&
|
|
219
|
+
routerCtx.session.type === LOGIN_BY_TOP_LEVEL &&
|
|
220
|
+
routerCtx.session.login &&
|
|
221
|
+
routerCtx.session.id;
|
|
222
|
+
// Top-level authority authentication middleware. It is registered before the
|
|
223
|
+
// server listens, and it is the only protocol middleware, so it runs first for
|
|
224
|
+
// every event on every socket.
|
|
225
|
+
protocol.use(async (routePath, routerCtx, _data, next) => {
|
|
226
|
+
const socket = routerCtx.socket;
|
|
227
|
+
// release all data flow controllers
|
|
228
|
+
if (routePath.startsWith("stream"))
|
|
229
|
+
return next();
|
|
230
|
+
// Except for the auth controller, which is publicly accessible, other
|
|
231
|
+
// business controllers must be authorized before they can be accessed
|
|
232
|
+
if (routePath === "auth")
|
|
233
|
+
return await next();
|
|
234
|
+
if (!routerCtx.session) {
|
|
235
|
+
throw new Error("Session does not exist in authentication middleware.");
|
|
236
|
+
}
|
|
237
|
+
if (isAuthenticated(routerCtx))
|
|
238
|
+
return await next();
|
|
239
|
+
ctx.logger.warn($t("TXT_CODE_auth_router.notAccess", {
|
|
240
|
+
id: socket.id,
|
|
241
|
+
address: socket.handshake.address,
|
|
242
|
+
event: routePath
|
|
243
|
+
}));
|
|
244
|
+
return protocol.error(routerCtx, "error", protocol.IGNORE, { disablePrint: true });
|
|
245
|
+
});
|
|
246
|
+
// The authentication controller itself.
|
|
247
|
+
protocol.on("auth", (routerCtx, data) => {
|
|
248
|
+
try {
|
|
249
|
+
let ip = routerCtx.socket.handshake.address;
|
|
250
|
+
// extract IPv4 address from IPv6 format
|
|
251
|
+
if (ip.startsWith("::ffff:"))
|
|
252
|
+
ip = ip.substring(7);
|
|
253
|
+
const config = ctx.settings.config;
|
|
254
|
+
const suppliedKey = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.alloc(0);
|
|
255
|
+
const configuredKey = Buffer.from(String(config.key ?? ""), "utf8");
|
|
256
|
+
if ((!config.whiteListPanelIp || config.whiteListPanelIps.includes(ip)) &&
|
|
257
|
+
configuredKey.length > 0 &&
|
|
258
|
+
suppliedKey.length === configuredKey.length &&
|
|
259
|
+
(0, node_crypto_1.timingSafeEqual)(suppliedKey, configuredKey)) {
|
|
260
|
+
// The authentication is passed, and the registered session is a trusted
|
|
261
|
+
// session.
|
|
262
|
+
ctx.logger.info($t("TXT_CODE_auth_router.access", {
|
|
263
|
+
id: routerCtx.socket.id,
|
|
264
|
+
address: routerCtx.socket.handshake.address
|
|
265
|
+
}));
|
|
266
|
+
routerCtx.session.key = String(data ?? "");
|
|
267
|
+
routerCtx.session.login = true;
|
|
268
|
+
routerCtx.session.id = routerCtx.socket.id;
|
|
269
|
+
routerCtx.session.type = LOGIN_BY_TOP_LEVEL;
|
|
270
|
+
routerCtx.session.stream = {};
|
|
271
|
+
protocol.msg(routerCtx, "auth", true);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
protocol.msg(routerCtx, "auth", false);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
protocol.msg(routerCtx, "auth", false);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
// Hang up on a connection that never authenticates. `ctx.setTimeout` is
|
|
282
|
+
// cancelled when the plugin unloads, so a pending timer leaves with it.
|
|
283
|
+
protocol.on("connection", (routerCtx) => {
|
|
284
|
+
const session = routerCtx.session;
|
|
285
|
+
ctx.setTimeout(() => {
|
|
286
|
+
if (!session.login) {
|
|
287
|
+
routerCtx.socket.disconnect();
|
|
288
|
+
ctx.logger.info($t("TXT_CODE_auth_router.disconnect", {
|
|
289
|
+
id: routerCtx.socket.id,
|
|
290
|
+
address: routerCtx.socket.handshake.address
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
}, AUTH_TIMEOUT);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
})();
|
|
298
|
+
|
|
299
|
+
module.exports = __webpack_exports__;
|
|
300
|
+
/******/ })()
|
|
301
|
+
;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "auth",
|
|
3
|
+
"name": "Authentication",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Owns the daemon's identity check: the top-level middleware that gates every protocol event, the key verification the panel authenticates with, and the panel IP whitelist. Removing this plugin leaves the daemon answering to anyone who connects.",
|
|
6
|
+
"priority": 20,
|
|
7
|
+
"backend": "backend/index.cjs"
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementspanel/epanel-plugin-auth",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Owns the daemon's identity check: the top-level middleware that gates every protocol event, the key verification the panel authenticates with, and the panel IP whitelist. Removing this plugin leaves the daemon answering to anyone who connects.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Csituka_D <694428809@qq.com> (https://github.com/JessDaodao)",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ElementsPanel/ElementsPanel"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.15.0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"daemon/",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./package.json": "./package.json",
|
|
24
|
+
"./daemon/plugin.json": "./daemon/plugin.json"
|
|
25
|
+
},
|
|
26
|
+
"elementspanel": {
|
|
27
|
+
"id": "auth",
|
|
28
|
+
"daemon": {
|
|
29
|
+
"directory": "daemon",
|
|
30
|
+
"folder": "auth"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@elementspanel/daemon": "1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"@elementspanel/daemon": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|