You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -72,6 +72,7 @@ This method is invoked when a class is compiled.</Description>
72
72
write !, "Installing WebTerminal application to " _ $NAMESPACE
73
73
set ns = $NAMESPACE // ought to be package home namespace!
74
74
set ^WebTerminal("HomeNamespace") = ns
75
+
set dbdir = $$$defdir
75
76
zn:ns'="%SYS" "%SYS"
76
77
do ##class(Security.System).GetInstallationSecuritySetting(.security)
77
78
set cspProperties("AutheEnabled") = 32 // password by default, 64 for no password
@@ -83,6 +84,8 @@ This method is invoked when a class is compiled.</Description>
83
84
set cspProperties("AutheEnabled") = 64
84
85
set cspProperties("Description") = "An application representing the open socket for /terminal application. Required since 2016.* Cache versions changed WebSocket behavior. PLEASE LEAVE THIS APPLICATION UNAUTHENTICATED, but do not worry: the socket won't accept anyone without the key."
85
86
set cspProperties("DispatchClass") = ""
87
+
set role = ..GetDBRole(dbdir)
88
+
set cspProperties("MatchRoles")=":%DB_CACHESYS" _ $case($get(role)'="", 1: ":"_role, :"")
86
89
do ..RegisterWebApplication("/terminalsocket", .cspProperties)
87
90
set status = ##Class(Config.Namespaces).Get("%All")
88
91
if ($$$ISERR(status)) { // no namespace %All
@@ -131,8 +134,9 @@ This method is invoked when a class is 'uncompiled'.</Description>
131
134
write !, "Uninstalling WebTerminal application from " _ $NAMESPACE
132
135
set ns = $NAMESPACE // has to be package home namespace!
133
136
if ($get(^WebTerminal("HomeNamespace")) = "") {
134
-
write "Terminal home namespace is not defined! Uninstalling will be skipped."
135
-
quit '$$$OK
137
+
set msg = "Please, set ^WebTerminal(""HomeNamespace"") global equal to " _
138
+
"the namespace WebTerminal was installed to before uninstalling."
139
+
quit $$$ERROR($$$GeneralError, msg)
136
140
} else {
137
141
set ns = ^WebTerminal("HomeNamespace")
138
142
}
@@ -157,5 +161,25 @@ This method is invoked when a class is 'uncompiled'.</Description>
157
161
QUIT $$$OK
158
162
]]></Implementation>
159
163
</Method>
164
+
165
+
<Methodname="GetDBRole">
166
+
<ClassMethod>1</ClassMethod>
167
+
<FormalSpec>directory:%String</FormalSpec>
168
+
<ReturnType>%String</ReturnType>
169
+
<Implementation><![CDATA[
170
+
quit:'$d(directory) ""
171
+
new $NAMESPACE
172
+
set $Namespace = "%SYS"
173
+
#dim db As SYS.Database
174
+
set db=##class(SYS.Database).%OpenId(directory)
175
+
if $Isobject(db) {
176
+
set resource = db.ResourceName
177
+
set role = resource // I'm assuming that default role exists
0 commit comments