Skip to content

Commit

Permalink
Enables accessing site via ilastik.apps.ebrains.eu
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaz-Vieira committed Jun 7, 2024
1 parent 47d8c1b commit 1fe1ee3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
8 changes: 5 additions & 3 deletions overlay/src/gui/widgets/fs_input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BucketFs, Filesystem, HttpFs } from "../../client/ilastik";
import { Path } from "../../util/parsed_url";
import { Path, Url } from "../../util/parsed_url";
import { CssClasses } from "../css_classes";
import { TabsWidget } from "./tabs_widget";
import { BucketFsInput, HttpFsInput } from "./value_input_widget";
Expand Down Expand Up @@ -78,12 +78,14 @@ export class FsInputWidget{
}

if(params.filesystemChoices.includes("http")){
let origin = Url.parse(window.location.origin + "/")
let protocol = origin.protocol as "http" | "https";
filesystemWidgets.push(
[
"HTTP",
new HttpFsInputForm({
parentElement: undefined,
value: new HttpFs({protocol: "https", hostname: "app.ilastik.org", path: Path.parse("/public/images")}),
value: new HttpFs({protocol, hostname: origin.hostname, path: Path.parse("/public/images")}),
})
],
)
Expand Down Expand Up @@ -116,4 +118,4 @@ export class FsInputWidget{
}
}
}
}
}
9 changes: 6 additions & 3 deletions overlay/src/gui/widgets/overlay_controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,28 @@ function uiGetUrlConfigs(): StartupConfigs{
export class OverlayControls{
element: HTMLElement;
constructor({
ilastikUrl=Url.parse("https://app.ilastik.org/"), viewer_driver, css
ilastikUrl, viewer_driver, css // ignore provided ilastikUrl and derive it from the current hostname
}: {
ilastikUrl?: Url, viewer_driver: IViewerDriver, css?: Url
}){
let inferredIlastikUrl = Url.parse(window.location.origin + "/");
console.log(`Ignoring ilastik url ${ilastikUrl} in favor of ${inferredIlastikUrl}`);
if(css){
injectCss(css)
}
this.element = createElement({tagName: "div", parentElement: viewer_driver.getContainerForWebilastikControls(), cssClasses: [CssClasses.ItkOverlayControls]})

let showSessionWidget = async () => {
let siteNamesResponse = await Session.getAvailableHpcSites({ilastikUrl})
let siteNamesResponse = await Session.getAvailableHpcSites({ilastikUrl: inferredIlastikUrl})
if(siteNamesResponse instanceof Error){
new ErrorPopupWidget({message: `Could not retrieve HPC site names: ${siteNamesResponse.message}`})
return
}
const configs = uiGetUrlConfigs();
const sessionManagementWidget = new SessionManagerWidget({
parentElement: this.element,
ilastikUrl, viewer_driver,
ilastikUrl: inferredIlastikUrl,
viewer_driver,
workflow_container: this.element,
hpcSiteNames: siteNamesResponse.available_sites,
configs,
Expand Down
6 changes: 3 additions & 3 deletions package_tree/etc/nginx/sites-available/webilastik.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
map $http_referer $allow_origin {
default "";
"~^(?<captured_origin>https://app\.ilastik\.org)(/.*)?$" $captured_origin;
"~^(?<captured_origin>https://app\.ilastik\.org|https://ilastik\.apps\.ebrains\.eu)(/.*)?$" $captured_origin;
# "~^(?<captured_origin>https?://dev\.web\.ilastik\.org)(/.*)?$" $captured_origin;
# "~^(?<captured_origin>https?://localhost(:[0-9]+)?)(/.*)?$" $captured_origin;
}

add_header "Access-Control-Allow-Origin" $allow_origin always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,X-Authorization-Refresh' always;

server {
server_name app.ilastik.org;
server_name app.ilastik.org ilastik.apps.ebrains.eu;

#listen 443 ssl;
#ssl_certificate /etc/webilastik/cert.pem;
Expand Down
7 changes: 5 additions & 2 deletions webilastik/server/session_allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ async def prompt_user_for_login(self, request: web.Request) -> web.Response:
status=301,
headers={
"Location": self.oidc_client.create_user_login_url(
redirect_uri=get_requested_url(request).updated_with(path=PurePosixPath("/api/login_successful")),
# redirect_uri must match what is registered in the OIDC here:
# https://wiki.ebrains.eu/bin/view/OIDC?srid=40W8jh7s#/client/webilastik
redirect_uri=Url.parse_or_raise("https://app.ilastik.org/api/login_successful"),
scopes=set([Scope.OPENID, Scope.GROUP, Scope.TEAM, Scope.EMAIL, Scope.PROFILE]),
).raw
}
Expand All @@ -180,7 +182,8 @@ async def login_successful(self, user_token: AccessToken, request: web.Request)
<head>
<meta charset="UTF-8">
<script>
window.opener.postMessage({user_token_js}, "https://app.ilastik.org"); //FIXME: don't hardcode domain
window.opener.postMessage({user_token_js}, "https://app.ilastik.org");
window.opener.postMessage({user_token_js}, "https://ilastik.apps.ebrains.eu");
window.close();
</script>
</head>
Expand Down

0 comments on commit 1fe1ee3

Please sign in to comment.