mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-28 19:27:50 +00:00
🔒️(backend) derive connection-test room max age from token TTL
Refactor CONNECTION_TEST_ROOM_MAX_AGE_SECONDS so it is no longer an independent setting but a quantity derived from (or added on top of) the token TTL. This prevents a misconfiguration where the token would outlive the delete-room callback. In that case, an attacker holding a valid token could recreate the room after the callback fired and escape the intended cleanup.
This commit is contained in:
committed by
aleb_the_flash
parent
1328098c45
commit
b593516802
@@ -1612,9 +1612,13 @@ class DiagnosticsViewSet(viewsets.ViewSet):
|
|||||||
# eject someone who stays connected. Schedule a hard DeleteRoom when Celery
|
# eject someone who stays connected. Schedule a hard DeleteRoom when Celery
|
||||||
# is available.
|
# is available.
|
||||||
if settings.CELERY_ENABLED:
|
if settings.CELERY_ENABLED:
|
||||||
|
max_age = (
|
||||||
|
settings.CONNECTION_TEST_TOKEN_TTL_SECONDS
|
||||||
|
+ settings.CONNECTION_TEST_ROOM_EXTRA_AGE_SECONDS
|
||||||
|
)
|
||||||
delete_connection_test_room.apply_async(
|
delete_connection_test_room.apply_async(
|
||||||
args=[room],
|
args=[room],
|
||||||
countdown=settings.CONNECTION_TEST_ROOM_MAX_AGE_SECONDS,
|
countdown=max_age,
|
||||||
)
|
)
|
||||||
|
|
||||||
return drf_response.Response(
|
return drf_response.Response(
|
||||||
|
|||||||
@@ -118,14 +118,15 @@ def test_api_diagnostics_connection_schedules_room_deletion(
|
|||||||
"""When Celery is enabled, schedule a hard room delete after max age."""
|
"""When Celery is enabled, schedule a hard room delete after max age."""
|
||||||
|
|
||||||
settings.CELERY_ENABLED = True
|
settings.CELERY_ENABLED = True
|
||||||
settings.CONNECTION_TEST_ROOM_MAX_AGE_SECONDS = 300
|
settings.CONNECTION_TEST_TOKEN_TTL_SECONDS = 300
|
||||||
|
settings.CONNECTION_TEST_ROOM_EXTRA_AGE_SECONDS = 10
|
||||||
settings.CONNECTION_TEST_ROOM_PREFIX = "connection-test"
|
settings.CONNECTION_TEST_ROOM_PREFIX = "connection-test"
|
||||||
|
|
||||||
response = client.post("/api/v1.0/diagnostics/connection/")
|
response = client.post("/api/v1.0/diagnostics/connection/")
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
room = response.json()["livekit"]["room"]
|
room = response.json()["livekit"]["room"]
|
||||||
mock_apply_async.assert_called_once_with(args=[room], countdown=300)
|
mock_apply_async.assert_called_once_with(args=[room], countdown=310)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("core.api.viewsets.delete_connection_test_room.apply_async")
|
@mock.patch("core.api.viewsets.delete_connection_test_room.apply_async")
|
||||||
|
|||||||
@@ -675,9 +675,13 @@ class Base(Configuration):
|
|||||||
environ_name="CONNECTION_TEST_TOKEN_TTL_SECONDS",
|
environ_name="CONNECTION_TEST_TOKEN_TTL_SECONDS",
|
||||||
environ_prefix=None,
|
environ_prefix=None,
|
||||||
)
|
)
|
||||||
CONNECTION_TEST_ROOM_MAX_AGE_SECONDS = values.PositiveIntegerValue(
|
# The effective room max age is always computed as
|
||||||
300,
|
# CONNECTION_TEST_TOKEN_TTL_SECONDS + this value. Token expiration does
|
||||||
environ_name="CONNECTION_TEST_ROOM_MAX_AGE_SECONDS",
|
# not automatically delete rooms, so once that age is reached, the
|
||||||
|
# cleanup worker will explicitly delete the room if it still exists.
|
||||||
|
CONNECTION_TEST_ROOM_EXTRA_AGE_SECONDS = values.PositiveIntegerValue(
|
||||||
|
10,
|
||||||
|
environ_name="CONNECTION_TEST_ROOM_EXTRA_AGE_SECONDS",
|
||||||
environ_prefix=None,
|
environ_prefix=None,
|
||||||
)
|
)
|
||||||
CONNECTION_TEST_ROOM_PREFIX = values.Value(
|
CONNECTION_TEST_ROOM_PREFIX = values.Value(
|
||||||
|
|||||||
Reference in New Issue
Block a user