Skip to content

Improve non-https behavior #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

## [2.1.0] - 2023-01-23

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ This might look like:

### Security

#### Unsecured (http) connections
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.

#### Dubious Ownership
Newer git versions may produce output like:
```
Expand Down
22 changes: 18 additions & 4 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,22 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
set InternalName = "/" _ InternalName
}

set externalBrowser = 0
set urlPrefix = ""
set urlPostfix = ""
if $IsObject($Get(%request)) && (%request.Application = "/api/atelier/") && '%request.Secure {
// In this case, won't work in an iframe. Need to launch in an external browser.
set externalBrowser = 1
set urlPrefix = "http://"_%request.CgiEnvs("HTTP_HOST")
set token = $Get(%session.Data("WebCSPToken"))
set token = ##class(%Atelier.v1.Utils.General).GetCSPToken("/isc/studio/usertemplates/dummy.csp",token)
set %session.Data("WebCSPToken") = token
set urlPostfix = "CSPCHD="_token
}

if (menuItemName = "Settings") {
set Action = 2
set Target = "/isc/studio/usertemplates/gitsourcecontrol/gitprojectsettings.csp?NSpace="_$namespace_"&Username="_$username
set Action = 2 + externalBrowser
set Target = urlPrefix _ "/isc/studio/usertemplates/gitsourcecontrol/gitprojectsettings.csp?Namespace="_$namespace_"&Username="_$username_"&"_urlPostfix
} elseif (menuItemName = "Init") {
if ##class(%File).CreateDirectoryChain(..TempFolder()) {
// cleanup items info
Expand All @@ -165,8 +178,8 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
set ec = ..MakeError("Unable to create folder "_..TempFolder())
}
} elseif (menuItemName = "GitWebUI") {
set Action = 2
set Target = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_$namespace_"/"_$zconvert(InternalName,"O","URL")
set Action = 2 + externalBrowser
set Target = urlPrefix _ "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_$namespace_"/"_$zconvert(InternalName,"O","URL")_"?"_urlPostfix
} elseif (menuItemName = "Export") || (menuItemName = "ExportForce") {
write !, "==export start==",!
set ec = ..ExportAll($case(menuItemName="ExportForce",1:$$$Force,:0))
Expand Down Expand Up @@ -1881,3 +1894,4 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
}

}