Skip to content

Commit 15b9d2e

Browse files
authored
Is730/serve studies (#747)
Implements a first prototype for issue #730 Adds new subsystem ``services/web/server/src/simcore_service_webserver/studies_access.py`` - Open services/web/server/tests/sandbox/*.md and click any link - If user is logged in, it copies the project and displays it - if anonymous, it creates a temporary user and does the previous step - Merges changes from PR #734 that contains the UI part. - queries id in url and opens page with specified study - fixes log out - preview of permissions (client-side only) Next step will incorporate privileges and user roles on the server side.
1 parent cfc73c1 commit 15b9d2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1150
-162
lines changed

.vscode-template/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"files.trimFinalNewlines": true,
1616
"files.trimTrailingWhitespace": true,
1717
"python.formatting.autopep8Args": [
18-
"-max-line-length", "140"
18+
"--max-line-length 140"
1919
],
2020
"python.linting.pylintEnabled": true,
2121
"python.linting.enabled": true,
@@ -26,5 +26,6 @@
2626
"[makefile]": {
2727
"editor.insertSpaces": false
2828
},
29+
"python.testing.pyTestEnabled": true,
2930
"autoDocstring.docstringFormat": "sphinx"
3031
}

scripts/openapi/oas_resolver/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WORKDIR /src
1212

1313
# update pip
1414
RUN pip install --no-cache-dir --upgrade \
15-
pip \
15+
pip~=19.1.1 \
1616
wheel \
1717
setuptools
1818

services/director/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ RUN apk add --no-cache \
4848
git
4949

5050
RUN $SC_PIP install --upgrade \
51-
pip \
51+
pip~=19.1.1 \
5252
wheel \
5353
setuptools
5454

services/dy-3dvis/simcoreparaviewweb/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ COPY scripts/docker/healthcheck_curl_host.py /healthcheck/healthcheck_curl_host.
4747
# set up oSparc env variables
4848
ENV SIMCORE_NODE_UUID="-1" \
4949
SIMCORE_USER_ID="-1" \
50-
STORAGE_ENDPOINT="=1" \
50+
STORAGE_ENDPOINT="=1" \
5151
S3_ENDPOINT="=1" \
5252
S3_ACCESS_KEY="-1" \
5353
S3_SECRET_KEY="-1" \
@@ -101,4 +101,4 @@ RUN export PATH="${PYENV_ROOT}/bin:$PATH" && \
101101
pip install /home/root/services/storage/client-sdk/python
102102
# copy script to get the inputs inside the local file system
103103
COPY services/dy-3dvis/simcoreparaviewweb/cgi_scripts /home/root/cgi_scripts
104-
ENTRYPOINT [ "/bin/bash", "docker/boot.sh" ]
104+
ENTRYPOINT [ "/bin/bash", "docker/boot.sh" ]

services/dy-modeling/server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ COPY services/dy-modeling/server/source /home/node/source
9090
COPY services/dy-modeling/server/docker /home/node/docker
9191
RUN npm install -y
9292

93-
ENTRYPOINT [ "/bin/bash", "/home/node/docker/boot.sh" ]
93+
ENTRYPOINT [ "/bin/bash", "/home/node/docker/boot.sh" ]

services/sidecar/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ RUN apk add --no-cache \
4444
libc-dev
4545

4646
RUN $SC_PIP install --upgrade \
47-
pip \
47+
pip~=19.1.1 \
4848
wheel \
4949
setuptools
5050

services/sidecar/src/sidecar/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def postprocess(self):
370370

371371
def inspect(self, celery_task, user_id, project_id, node_id):
372372
log.debug("ENTERING inspect pipeline:node %s: %s", project_id, node_id)
373-
# import pdb; pdb.set_trace()
373+
374374
next_task_nodes = []
375375
do_run = False
376376

services/storage/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ RUN apk add --no-cache \
4444
linux-headers
4545

4646
RUN $SC_PIP install --upgrade \
47-
pip \
47+
pip~=19.1.1 \
4848
wheel \
4949
setuptools
5050

services/storage/tests/test_dsm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import io
1010
import json
1111
import os
12-
import pdb
1312
import urllib
1413
import uuid
1514
from pathlib import Path

services/web/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN apk add --no-cache \
4949
libffi-dev
5050

5151
RUN $SC_PIP install --upgrade \
52-
pip \
52+
pip~=19.1.1 \
5353
wheel \
5454
setuptools
5555

services/web/client/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
}
2525
],
2626
"no-warning-comments": "off"
27+
},
28+
"env": {
29+
"browser": true
2730
}
2831
}

services/web/client/compile.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"targets": [
33
{
44
"type": "source",
5-
"outputPath": "source-output",
5+
"outputPath": "source-output"
6+
},
7+
{
8+
"type": "build",
9+
"outputPath": "build-output",
610
"bundle": {
711
"include": [
812
"qx.*"
913
]
1014
}
11-
},
12-
{
13-
"type": "build",
14-
"outputPath": "build-output"
1515
}
1616
],
1717
"defaultTarget": "source",

services/web/client/package-lock.json

Lines changed: 29 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/web/client/source/class/qxapp/Application.js

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,19 @@ qx.Class.define("qxapp.Application", {
6969
this.__restart();
7070
}, this);
7171

72-
this.__restart();
72+
this.__initRouting();
73+
},
74+
75+
__initRouting: function() {
76+
// Route: /#/study/{id}
77+
// TODO: PC -> IP consider regex for uuid, i.e. /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/ ???
78+
let result = /#\/study\/([0-9a-zA-Z\-]+)/.exec(window.location.hash);
79+
if (result) {
80+
qxapp.utils.Utils.cookie.deleteCookie("user");
81+
qxapp.auth.Manager.getInstance().validateToken(() => this.__loadMainPage(result[1]), this.__loadLoginPage, this);
82+
} else {
83+
this.__restart();
84+
}
7385
},
7486

7587
__restart: function() {
@@ -80,35 +92,37 @@ qx.Class.define("qxapp.Application", {
8092
isLogged = true;
8193
}
8294

83-
let view = null;
84-
let options = null;
85-
8695
if (isLogged) {
87-
this.__connectWebSocket();
88-
view = new qxapp.desktop.LayoutManager();
89-
options = {
90-
top: 0,
91-
bottom: 0,
92-
left: 0,
93-
right: 0
94-
};
95-
this.__loadView(view, options);
96+
this.__loadMainPage();
9697
} else {
97-
this.__disconnectWebSocket();
98-
view = new qxapp.auth.MainView();
99-
view.addListener("done", function(msg) {
100-
this.__restart();
101-
}, this);
102-
options = {
103-
top: "10%",
104-
bottom: 0,
105-
left: 0,
106-
right: 0
107-
};
108-
this.__loadView(view, options);
98+
qxapp.auth.Manager.getInstance().validateToken(this.__loadMainPage, this.__loadLoginPage, this);
10999
}
110100
},
111101

102+
__loadLoginPage: function() {
103+
this.__disconnectWebSocket();
104+
const view = new qxapp.auth.LoginPage();
105+
view.addListener("done", function(msg) {
106+
this.__restart();
107+
}, this);
108+
this.__loadView(view, {
109+
top: "10%",
110+
bottom: 0,
111+
left: 0,
112+
right: 0
113+
});
114+
},
115+
116+
__loadMainPage: function(studyId) {
117+
this.__connectWebSocket();
118+
this.__loadView(new qxapp.desktop.MainPage(studyId), {
119+
top: 0,
120+
bottom: 0,
121+
left: 0,
122+
right: 0
123+
});
124+
},
125+
112126
__loadView: function(view, options) {
113127
this.assert(view!==null);
114128
// Update root document and currentness

services/web/client/source/class/qxapp/auth/Data.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ qx.Class.define("qxapp.auth.Data", {
3131
auth: {
3232
init: null,
3333
nullable: true,
34-
check: "qx.io.request.authentication.Basic"
34+
check: "qxapp.io.request.authentication.Token"
3535
},
3636

3737
/**
@@ -48,14 +48,20 @@ qx.Class.define("qxapp.auth.Data", {
4848

4949
setToken: function(token) {
5050
if (token) {
51-
this.setAuth(new qx.io.request.authentication.Basic(token, null));
51+
qxapp.utils.Utils.cookie.setCookie("user", token);
52+
this.setAuth(new qxapp.io.request.authentication.Token(token));
5253
}
5354
},
5455

5556
resetToken: function() {
57+
qxapp.utils.Utils.cookie.setCookie("user", "logout");
5658
this.resetAuth();
5759
},
5860

61+
isLogout: function() {
62+
return qxapp.utils.Utils.cookie.getCookie("user") === "logout";
63+
},
64+
5965
getUserName: function() {
6066
const email = qxapp.auth.Data.getInstance().getEmail();
6167
if (email) {

0 commit comments

Comments
 (0)