Skip to content

Commit 9e7e84d

Browse files
authored
Fix/session secrets (#830)
Sets unique secret session key for all webserver replicas. This was preventing scaling up the webserver since each would encode differently the session tokens - session moved from ``servicelib`` into ``webserver`` - moved session secret-key to webserver service **configuration** ``session.secret_key`` so it can scale: configuration is shared by all containers in a service. - Fix warning in master deployment ``WARNING:aiohttp_session:Cannot decrypt cookie value, create a new fresh session``
1 parent 5b02a8a commit 9e7e84d

File tree

16 files changed

+128
-114
lines changed

16 files changed

+128
-114
lines changed

packages/service-library/requirements/_base.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ openapi-core~=0.8.0 # there is an issue validating "number" type 3 is considered
99

1010
aiohttp
1111
aiopg[sa]
12-
cryptography
1312
ujson
1413
werkzeug
1514
jsonschema
16-
aiohttp_session[secure] # TODO: eliminate this dependency or make it optional!

packages/service-library/requirements/_base.txt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,23 @@
44
#
55
# pip-compile --output-file=_base.txt _base.in
66
#
7-
aiohttp-session[secure]==2.7.0
87
aiohttp==3.5.4
98
aiopg[sa]==0.16.0
10-
asn1crypto==0.24.0 # via cryptography
119
async-timeout==3.0.1 # via aiohttp
12-
attrs==19.1.0 # via aiohttp, openapi-core
13-
cffi==1.12.3 # via cryptography
10+
attrs==19.1.0 # via aiohttp, jsonschema, openapi-core
1411
chardet==3.0.4 # via aiohttp
15-
cryptography==2.6.1
1612
idna-ssl==1.1.0 # via aiohttp
1713
idna==2.8 # via idna-ssl, yarl
18-
jsonschema==2.6.0
14+
jsonschema==3.0.1
1915
lazy-object-proxy==1.4.1 # via openapi-core
2016
multidict==4.5.2 # via aiohttp, yarl
2117
openapi-core==0.8.0
22-
openapi-spec-validator==0.2.6 # via openapi-core
23-
pathlib==1.0.1 # via openapi-spec-validator
18+
openapi-spec-validator==0.2.7 # via openapi-core
2419
psycopg2-binary==2.8.2
25-
pycparser==2.19 # via cffi
20+
pyrsistent==0.15.2 # via jsonschema
2621
pyyaml==5.1
27-
six==1.12.0 # via cryptography, openapi-core, openapi-spec-validator
28-
sqlalchemy[postgresql_psycopg2binary]==1.3.3
22+
six==1.12.0 # via jsonschema, openapi-core, openapi-spec-validator, pyrsistent
23+
sqlalchemy[postgresql_psycopg2binary]==1.3.4
2924
strict-rfc3339==0.7 # via openapi-core
3025
typing-extensions==3.7.2 # via aiohttp
3126
ujson==1.35

packages/service-library/requirements/_test.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,48 @@
44
#
55
# pip-compile --output-file=_test.txt _test.in
66
#
7-
aiohttp-session[secure]==2.7.0
87
aiohttp==3.5.4
98
aiopg[sa]==0.16.0
10-
asn1crypto==0.24.0
119
astroid==2.2.5 # via pylint
1210
async-timeout==3.0.1
1311
atomicwrites==1.3.0 # via pytest
1412
attrs==19.1.0
1513
certifi==2019.3.9 # via requests
16-
cffi==1.12.3
1714
chardet==3.0.4
1815
coverage==4.5.3 # via coveralls, pytest-cov
1916
coveralls==1.7.0
20-
cryptography==2.6.1
2117
docopt==0.6.2 # via coveralls
2218
idna-ssl==1.1.0
2319
idna==2.8
20+
importlib-metadata==0.15 # via pluggy
2421
isort==4.3.20 # via pylint
25-
jsonschema==2.6.0
22+
jsonschema==3.0.1
2623
lazy-object-proxy==1.4.1
2724
mccabe==0.6.1 # via pylint
2825
more-itertools==7.0.0 # via pytest
2926
multidict==4.5.2
3027
openapi-core==0.8.0
31-
openapi-spec-validator==0.2.6
32-
pathlib==1.0.1
33-
pluggy==0.11.0 # via pytest
28+
openapi-spec-validator==0.2.7
29+
pluggy==0.12.0 # via pytest
3430
psycopg2-binary==2.8.2
3531
py==1.8.0 # via pytest
36-
pycparser==2.19
3732
pylint==2.3.1
33+
pyrsistent==0.15.2
3834
pytest-aiohttp==0.3.0
3935
pytest-cov==2.7.1
40-
pytest-runner==4.4
36+
pytest-runner==5.1
4137
pytest==4.5.0
4238
pyyaml==5.1
4339
requests==2.22.0 # via coveralls
4440
six==1.12.0
45-
sqlalchemy[postgresql_psycopg2binary]==1.3.3
41+
sqlalchemy[postgresql_psycopg2binary]==1.3.4
4642
strict-rfc3339==0.7
4743
typed-ast==1.3.5 # via astroid
4844
typing-extensions==3.7.2
4945
ujson==1.35
50-
urllib3==1.25.2 # via requests
46+
urllib3==1.25.3 # via requests
5147
wcwidth==0.1.7 # via pytest
5248
werkzeug==0.15.4
5349
wrapt==1.11.1 # via astroid
5450
yarl==1.3.0
51+
zipp==0.5.1 # via importlib-metadata

packages/service-library/src/servicelib/session.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

services/web/server/requirements/_base.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ jsonschema<3 # FIXME: openapi-spec-validator==0.2.6 (used in tests) requi
1313
aio-pika==2.9.0 # TODO: upgrade code before !!
1414
aiohttp
1515
aiohttp_jinja2
16+
aiohttp_session[secure]
1617
aiohttp_security
1718
aiopg[sa]
1819
aiosmtplib
1920
asyncpg
2021
celery
22+
cryptography
2123
change_case
2224
jinja_app_loader
2325
passlib

services/web/server/requirements/_base.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ aadict==0.2.3 # via asset
88
aio-pika==2.9.0
99
aiohttp-jinja2==1.1.1
1010
aiohttp-security==0.4.0
11+
aiohttp-session[secure]==2.7.0
1112
aiohttp==3.5.4
1213
aiopg[sa]==0.16.0
1314
aiosmtplib==1.0.5
1415
amqp==2.4.2 # via kombu
16+
asn1crypto==0.24.0 # via cryptography
1517
asset==0.6.12 # via passwordmeter
1618
async-timeout==3.0.1 # via aiohttp
1719
asyncpg==0.18.3
1820
attrs==19.1.0 # via aiohttp, openapi-core
1921
billiard==3.6.0.0 # via celery
2022
celery==4.3.0
23+
cffi==1.12.3 # via cryptography
2124
change-case==0.5.2
2225
chardet==3.0.4 # via aiohttp
26+
cryptography==2.6.1
2327
globre==0.1.5 # via asset
2428
idna-ssl==1.1.0 # via aiohttp
2529
idna==2.8 # via idna-ssl, yarl
@@ -32,20 +36,20 @@ lazy-object-proxy==1.4.1 # via openapi-core
3236
markupsafe==1.1.1 # via jinja2
3337
multidict==4.5.2 # via aiohttp, yarl
3438
openapi-core==0.8.0
35-
openapi-spec-validator==0.2.6 # via openapi-core
39+
openapi-spec-validator==0.2.7 # via openapi-core
3640
passlib==1.7.1
3741
passwordmeter==0.1.8
38-
pathlib==1.0.1 # via openapi-spec-validator
3942
pika==0.10.0 # via aio-pika
4043
psycopg2-binary==2.8.2
41-
python-engineio==3.5.1 # via python-socketio
42-
python-socketio==4.0.1
44+
pycparser==2.19 # via cffi
45+
python-engineio==3.7.0 # via python-socketio
46+
python-socketio==4.0.3
4347
pytz==2019.1 # via celery
4448
pyyaml==5.1
4549
semantic-version==2.6.0
4650
shortuuid==0.5.0 # via aio-pika
47-
six==1.12.0 # via aadict, asset, openapi-core, openapi-spec-validator, python-engineio, python-socketio, tenacity
48-
sqlalchemy[postgresql_psycopg2binary]==1.3.3
51+
six==1.12.0 # via aadict, asset, cryptography, openapi-core, openapi-spec-validator, python-engineio, python-socketio, tenacity
52+
sqlalchemy[postgresql_psycopg2binary]==1.3.4
4953
strict-rfc3339==0.7 # via openapi-core
5054
tenacity==5.0.4
5155
trafaret-config==2.0.2

services/web/server/requirements/_test.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ aadict==0.2.3
88
aio-pika==2.9.0
99
aiohttp-jinja2==1.1.1
1010
aiohttp-security==0.4.0
11+
aiohttp-session[secure]==2.7.0
1112
aiohttp==3.5.4
1213
aiopg[sa]==0.16.0
1314
aiosmtplib==1.0.5
1415
amqp==2.4.2
16+
asn1crypto==0.24.0
1517
asset==0.6.12
1618
astroid==2.2.5 # via pylint
1719
async-timeout==3.0.1
@@ -21,18 +23,20 @@ attrs==19.1.0
2123
billiard==3.6.0.0
2224
celery==4.3.0
2325
certifi==2019.3.9 # via requests
26+
cffi==1.12.3
2427
change-case==0.5.2
2528
chardet==3.0.4
2629
codecov==2.0.15
2730
coverage==4.5.3 # via codecov, coveralls, pytest-cov
2831
coveralls==1.7.0
29-
docker-pycreds==0.4.0 # via docker
30-
docker==3.7.2
32+
cryptography==2.6.1
33+
docker==4.0.1
3134
docopt==0.6.2 # via coveralls
3235
faker==1.0.7
3336
globre==0.1.5
3437
idna-ssl==1.1.0
3538
idna==2.8
39+
importlib-metadata==0.16 # via pluggy
3640
isort==4.3.20 # via pylint
3741
jinja-app-loader==1.0.2
3842
jinja2==2.10.1
@@ -45,41 +49,42 @@ mccabe==0.6.1 # via pylint
4549
more-itertools==7.0.0 # via pytest
4650
multidict==4.5.2
4751
openapi-core==0.8.0
48-
openapi-spec-validator==0.2.6
52+
openapi-spec-validator==0.2.7
4953
passlib==1.7.1
5054
passwordmeter==0.1.8
51-
pathlib==1.0.1
5255
pika==0.10.0
53-
pluggy==0.11.0 # via pytest
56+
pluggy==0.12.0 # via pytest
5457
psycopg2-binary==2.8.2
5558
py==1.8.0 # via pytest
59+
pycparser==2.19
5660
pylint==2.3.1
5761
pytest-aiohttp==0.3.0
5862
pytest-cov==2.7.1
5963
pytest-docker==0.6.1
6064
pytest-mock==1.10.4
61-
pytest-runner==4.4
65+
pytest-runner==5.1
6266
pytest==4.5.0
6367
python-dateutil==2.8.0 # via faker
64-
python-engineio==3.5.1
65-
python-socketio==4.0.1
68+
python-engineio==3.7.0
69+
python-socketio==4.0.3
6670
pytz==2019.1
6771
pyyaml==5.1
6872
requests==2.22.0 # via codecov, coveralls, docker
6973
semantic-version==2.6.0
7074
shortuuid==0.5.0
7175
six==1.12.0
72-
sqlalchemy[postgresql_psycopg2binary]==1.3.3
76+
sqlalchemy[postgresql_psycopg2binary]==1.3.4
7377
strict-rfc3339==0.7
7478
tenacity==5.0.4
7579
text-unidecode==1.2 # via faker
7680
trafaret-config==2.0.2
7781
trafaret==1.2.0
7882
typed-ast==1.3.5 # via astroid
7983
typing-extensions==3.7.2
80-
urllib3==1.24.3 # via requests
84+
urllib3==1.25.3 # via requests
8185
vine==1.3.0
8286
wcwidth==0.1.7 # via pytest
8387
websocket-client==0.56.0 # via docker
8488
wrapt==1.11.1 # via astroid
8589
yarl==1.3.0
90+
zipp==0.5.1 # via importlib-metadata

services/web/server/src/simcore_service_webserver/application_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from servicelib import application_keys # pylint:disable=unused-import
2424

2525
from . import (computation_config, db_config, email_config, rest_config,
26-
storage_config)
26+
storage_config, session_config)
2727
from .director import config as director_config
2828
from .login import config as login_config
2929
from .projects import config as projects_config
@@ -54,7 +54,8 @@ def create_schema():
5454
email_config.CONFIG_SECTION_NAME: email_config.schema,
5555
computation_config.CONFIG_SECTION_NAME: computation_config.schema,
5656
storage_config.CONFIG_SECTION_NAME: storage_config.schema,
57-
T.Key(login_config.CONFIG_SECTION_NAME, optional=True): login_config.schema
57+
T.Key(login_config.CONFIG_SECTION_NAME, optional=True): login_config.schema,
58+
session_config.CONFIG_SECTION_NAME: session_config.schema,
5859
#s3_config.CONFIG_SECTION_NAME: s3_config.schema
5960
#TODO: enable when sockets are refactored
6061
})

services/web/server/src/simcore_service_webserver/config/host-dev-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ projects:
5555
storage:
5656
host: storage
5757
port: 11111
58+
session:
59+
secret_key: "TODO: Replace with a key of at least length 32"

services/web/server/src/simcore_service_webserver/config/server-defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ rest:
5454
- http://localhost:9081
5555
projects:
5656
location: http://localhost:8043/api/specs/webserver/v0/components/schemas/project-v0.0.1.json
57+
session:
58+
secret_key: "TODO: Replace with a key of at least length 32"

0 commit comments

Comments
 (0)