Skip to content

Commit 787a21f

Browse files
security options for unknownUsers, fixes
1 parent d6baba0 commit 787a21f

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

%WebTerminal/Engine.cls.xml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All operations with opened WebSocket placed here.</Description>
99

1010
<UDLText name="T">
1111
<Content><![CDATA[
12-
// USER CONSTANTS START
12+
// USER CONSTANTS BEGIN
1313
1414
]]></Content>
1515
</UDLText>
@@ -20,6 +20,20 @@ How long to wait for authorization key when connection established</Description>
2020
<Default>5</Default>
2121
</Parameter>
2222

23+
<Parameter name="authorizeUsers">
24+
<Description>
25+
Use user privileges and require authorization for them</Description>
26+
<Default>1</Default>
27+
</Parameter>
28+
29+
<Parameter name="allowUnknownUser">
30+
<Description>
31+
Allow accessing terminal for unregistered users (unknownUser).
32+
Anyway, changing this constant to 1 can make a big hole in security,
33+
so change it at your own risk!</Description>
34+
<Default>0</Default>
35+
</Parameter>
36+
2337
<UDLText name="T">
2438
<Content><![CDATA[
2539
// USER CONSTANTS END
@@ -757,15 +771,25 @@ the client - it includes authorization key.</Description>
757771
ZNSPACE $LISTGET(lb, 7) // namespace
758772
759773
set user = $LISTGET($LISTGET(lb, 16), 1) // user
760-
set loginStatus = ##class(%SYSTEM.Security).Login($LISTGET($LISTGET(lb, 16), 1))
774+
if (user = "UnknownUser") && (..#allowUnknownUser '= 1) {
775+
set ok = 0
776+
do ..SendData("!UnknownUser disallowed.", ..ConstClientAuthorizationStatus)
777+
QUIT
778+
}
779+
780+
if (..#authorizeUsers = 1) {
781+
set loginStatus = ##class(%SYSTEM.Security).Login($LISTGET($LISTGET(lb, 16), 1))
782+
} else {
783+
set loginStatus = 1
784+
}
761785
if ($$$ISOK(loginStatus)) {
762786
do ..SendData(user,..ConstClientLoginInfo)
763787
} else {
764788
do ..SendData("!",..ConstClientLoginInfo)
765789
}
766790
767791
set ok = loginStatus
768-
BREAK
792+
QUIT
769793
770794
}
771795
}

csp/webTerminal/js/application.js.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
var application = new function() {
88
9-
var version = "0.9.9.5 beta"; // link to language.js
9+
var version = "0.9.9.6 beta"; // link to language.js
1010
this.debug = false; // remove for release
1111
this.debugUrlPart = "172.27.25.133:57772"; // in-debug mode
1212

csp/webTerminal/js/language.js.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var lang = new function() {
2929
0: parser.highlightHTML("/help"),
3030
1: parser.highlightHTML("/tip"),
3131
2: parser.highlightHTML("/connect"),
32-
3: "0.9.9.5 beta",
32+
3: "0.9.9.6 beta",
3333
4: 1,
3434
5: parser.highlightHTML("set test = 12"),
3535
6: parser.highlightHTML("write test"),

csp/webTerminal/js/terminal.js.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ var terminal = new function() {
313313
server.requestAutocompleteFile(data || terminal.namespace.getCorrectFileName());
314314
} break;
315315
case terminal.clientActions.AUTHORIZATION_STATUS: {
316-
if (!settings.get_cleanStartup()) {
316+
if (data.charAt(0) === "!") {
317+
terminal.output.write(data.substr(1))
318+
} else if (!settings.get_cleanStartup()) {
317319
terminal.output.write((data == "1")?lang.get(3):lang.get(5));
318320
}
319321
terminal.ready = true; // TERMINAL READY

0 commit comments

Comments
 (0)