Skip to content

Commit a7a4a49

Browse files
committed
Improve non-https behavior
Even localhost has issues. This helps a lot.
1 parent 432a1ca commit a7a4a49

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111
- Link from WebUI to Settings page works properly (#230)
12+
- VSCode Web Views launch in external browser when connecting over unsecured connections (#227)
1213

1314
## [2.1.0] - 2023-01-23
1415

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ This might look like:
5151
5252
### Security
5353
54+
#### Unsecured (http) connections
55+
You really should be connecting to IRIS over a secured (https) connection. If you're not, web pages in this extension will launch in an external browser, because constraints around session cookies keep them from working properly in VSCode.
56+
5457
#### Dubious Ownership
5558
Newer git versions may produce output like:
5659
```

cls/SourceControl/Git/Utils.cls

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,22 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
148148
set InternalName = "/" _ InternalName
149149
}
150150

151+
set externalBrowser = 0
152+
set urlPrefix = ""
153+
set urlPostfix = ""
154+
if $IsObject($Get(%request)) && (%request.Application = "/api/atelier/") && '%request.Secure {
155+
// In this case, won't work in an iframe. Need to launch in an external browser.
156+
set externalBrowser = 1
157+
set urlPrefix = "http://"_%request.CgiEnvs("HTTP_HOST")
158+
set token = $Get(%session.Data("WebCSPToken"))
159+
set token = ##class(%Atelier.v1.Utils.General).GetCSPToken("/isc/studio/usertemplates/dummy.csp",token)
160+
set %session.Data("WebCSPToken") = token
161+
set urlPostfix = "CSPCHD="_token
162+
}
163+
151164
if (menuItemName = "Settings") {
152-
set Action = 2
153-
set Target = "/isc/studio/usertemplates/gitsourcecontrol/gitprojectsettings.csp?NSpace="_$namespace_"&Username="_$username
165+
set Action = 2 + externalBrowser
166+
set Target = urlPrefix _ "/isc/studio/usertemplates/gitsourcecontrol/gitprojectsettings.csp?Namespace="_$namespace_"&Username="_$username_"&"_urlPostfix
154167
} elseif (menuItemName = "Init") {
155168
if ##class(%File).CreateDirectoryChain(..TempFolder()) {
156169
// cleanup items info
@@ -165,8 +178,8 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
165178
set ec = ..MakeError("Unable to create folder "_..TempFolder())
166179
}
167180
} elseif (menuItemName = "GitWebUI") {
168-
set Action = 2
169-
set Target = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_$namespace_"/"_$zconvert(InternalName,"O","URL")
181+
set Action = 2 + externalBrowser
182+
set Target = urlPrefix _ "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_$namespace_"/"_$zconvert(InternalName,"O","URL")_"?"_urlPostfix
170183
} elseif (menuItemName = "Export") || (menuItemName = "ExportForce") {
171184
write !, "==export start==",!
172185
set ec = ..ExportAll($case(menuItemName="ExportForce",1:$$$Force,:0))
@@ -1881,3 +1894,4 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
18811894
}
18821895

18831896
}
1897+

0 commit comments

Comments
 (0)