Skip to content

Commit 4748ad7

Browse files
author
maxim-lixakov
committed
[DOP-21268] - add SessionSettings
1 parent e1efdaa commit 4748ad7

File tree

13 files changed

+100
-22
lines changed

13 files changed

+100
-22
lines changed

.env.docker

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@ SYNCMASTER__LOGGING__SETUP=True
99
SYNCMASTER__LOGGING__PRESET=colored
1010
SYNCMASTER__LOG_URL_TEMPLATE=https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}
1111

12+
# Session
13+
SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key
14+
1215
# Encrypt / Decrypt credentials data
1316
SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
1417

1518
# Postgres
1619
SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@db:5432/syncmaster
1720

21+
# TODO: add to KeycloakAuthProvider documentation about creating new realms, add users, etc.
1822
# KEYCLOAK Auth
1923
SYNCMASTER__AUTH__SERVER_URL=http://keycloak:8080/
20-
SYNCMASTER__AUTH__REALM_NAME=fastapi-realm
21-
SYNCMASTER__AUTH__CLIENT_ID=fastapi-client
22-
SYNCMASTER__AUTH__CLIENT_SECRET=VoLrqGz1HGjp6MiwzRaGWIu7z7imKIHb
24+
SYNCMASTER__AUTH__REALM_NAME=manually_created
25+
SYNCMASTER__AUTH__CLIENT_ID=manually_created
26+
SYNCMASTER__AUTH__CLIENT_SECRET=generated_by_keycloak
2327
SYNCMASTER__AUTH__REDIRECT_URI=http://localhost:8000/v1/auth/callback
24-
SYNCMASTER__AUTH__ADMIN_REDIRECT_URI=http://localhost:8000/v1/auth/callback
2528
SYNCMASTER__AUTH__SCOPE=email
26-
SYNCMASTER__AUTH__KEYCLOAK_INTROSPECTION_DELAY=60
2729
SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.keycloak_provider.KeycloakAuthProvider
28-
SYNCMASTER__AUTH__KEYCLOAK_TOKEN_URL=http://keycloak:8080/realms/fastapi-realm/protocol/openid-connect/token
2930

3031
# Dummy Auth
3132
SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.dummy_provider.DummyAuthProvider
32-
SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=bae1thahr8Iyaisai0kohvoh1aeg5quu
33+
SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=secret
3334

3435
# RabbitMQ
3536
SYNCMASTER__BROKER__URL=amqp://guest:guest@rabbitmq:5672/

.env.local

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export SYNCMASTER__LOGGING__SETUP=True
99
export SYNCMASTER__LOGGING__PRESET=colored
1010
export SYNCMASTER__LOG_URL_TEMPLATE="https://grafana.example.com?correlation_id={{ correlation_id }}&run_id={{ run.id }}"
1111

12+
# Session
13+
export SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key
14+
1215
# Encrypt / Decrypt credentials data
1316
export SYNCMASTER__CRYPTO_KEY=UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
1417

@@ -17,7 +20,7 @@ export SYNCMASTER__DATABASE__URL=postgresql+asyncpg://syncmaster:changeme@localh
1720

1821
# Auth
1922
export SYNCMASTER__AUTH__PROVIDER=syncmaster.backend.providers.auth.dummy_provider.DummyAuthProvider
20-
export SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=bae1thahr8Iyaisai0kohvoh1aeg5quu
23+
export SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=secret
2124

2225
# RabbitMQ
2326
export SYNCMASTER__BROKER__URL=amqp://guest:guest@localhost:5672/

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build:
1717
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry install --no-root --all-extras --with docs --without dev,test
1818
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH python -m poetry show -v
1919
- python -m pip list -v
20-
- SYNCMASTER__DATABASE__URL=postgresql+psycopg://fake:[email protected]:5432/fake SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ SYNCMASTER__CRYPTO_KEY=crypto_key SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=fakepython python -m syncmaster.backend.export_openapi_schema docs/_static/openapi.json
20+
- SYNCMASTER__DATABASE__URL=postgresql+psycopg://fake:[email protected]:5432/fake SYNCMASTER__SERVER__SESSION__SECRET_KEY=session_secret_key SYNCMASTER__BROKER__URL=amqp://fake:faket@fake:5672/ SYNCMASTER__CRYPTO_KEY=crypto_key SYNCMASTER__AUTH__ACCESS_TOKEN__SECRET_KEY=fakepython python -m syncmaster.backend.export_openapi_schema docs/_static/openapi.json
2121

2222
sphinx:
2323
configuration: docs/conf.py

docs/backend/configuration/cors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ CORS settings
55

66
These settings used to control `CORS <https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS>`_ options.
77

8-
.. autopydantic_model:: syncmaster.settings.server.cors.CORSSettings
8+
.. autopydantic_model:: syncmaster.backend.settings.server.cors.CORSSettings

docs/backend/configuration/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Configuration
1111
database
1212
broker
1313
logging
14+
session
1415
cors
1516
debug
1617
monitoring

docs/backend/configuration/monitoring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ REST API server provides the following endpoints with Prometheus compatible metr
1313

1414
These endpoints are enabled and configured using settings below:
1515

16-
.. autopydantic_model:: syncmaster.settings.server.monitoring.MonitoringSettings
16+
.. autopydantic_model:: syncmaster.backend.settings.server.monitoring.MonitoringSettings

docs/backend/configuration/openapi.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ OpenAPI settings
55

66
These settings used to control exposing OpenAPI.json and SwaggerUI/ReDoc endpoints.
77

8-
.. autopydantic_model:: syncmaster.settings.server.openapi.OpenAPISettings
9-
.. autopydantic_model:: syncmaster.settings.server.openapi.SwaggerSettings
10-
.. autopydantic_model:: syncmaster.settings.server.openapi.RedocSettings
11-
.. autopydantic_model:: syncmaster.settings.server.openapi.LogoSettings
12-
.. autopydantic_model:: syncmaster.settings.server.openapi.FaviconSettings
8+
.. autopydantic_model:: syncmaster.backend.settings.server.openapi.OpenAPISettings
9+
.. autopydantic_model:: syncmaster.backend.settings.server.openapi.SwaggerSettings
10+
.. autopydantic_model:: syncmaster.backend.settings.server.openapi.RedocSettings
11+
.. autopydantic_model:: syncmaster.backend.settings.server.openapi.LogoSettings
12+
.. autopydantic_model:: syncmaster.backend.settings.server.openapi.FaviconSettings
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _backend-configuration-server-session:
2+
3+
Session settings
4+
================
5+
6+
These settings used to control `Session <https://developer.mozilla.org/en-US/docs/Web/HTTP/Session>`_ options.
7+
8+
.. autopydantic_model:: syncmaster.backend.settings.server.session.SessionSettings

docs/backend/configuration/static_files.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Serving static files
55

66
These settings used to control serving static files by a server.
77

8-
.. autopydantic_model:: syncmaster.settings.server.static_files.StaticFilesSettings
8+
.. autopydantic_model:: syncmaster.backend.settings.server.static_files.StaticFilesSettings

syncmaster/backend/middlewares/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ def apply_middlewares(
2929
apply_request_id_middleware(application, settings.server.request_id)
3030
apply_openapi_middleware(application, settings.server.openapi)
3131
apply_static_files(application, settings.server.static_files)
32-
apply_session_middleware(application)
32+
apply_session_middleware(application, settings.server.session)
3333

3434
return application

0 commit comments

Comments
 (0)