Skip to content

Commit c6bd166

Browse files
committed
Add checks for new settings
1 parent dfab919 commit c6bd166

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

src/reactpy_django/checks.py

+52-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def reactpy_warnings(app_configs, **kwargs):
220220
)
221221
)
222222

223-
# Check if REACTPY_CLEAN_SESSION is not a valid property
223+
# Check if user misspelled REACTPY_CLEAN_SESSIONS
224224
if getattr(settings, "REACTPY_CLEAN_SESSION", None):
225225
warnings.append(
226226
Warning(
@@ -230,6 +230,27 @@ def reactpy_warnings(app_configs, **kwargs):
230230
)
231231
)
232232

233+
# Check if REACTPY_AUTH_TOKEN_TIMEOUT is a large value
234+
auth_token_timeout = config.REACTPY_AUTH_TOKEN_TIMEOUT
235+
if isinstance(auth_token_timeout, int) and auth_token_timeout > 120:
236+
warnings.append(
237+
Warning(
238+
"REACTPY_AUTH_TOKEN_TIMEOUT is set to a very large value.",
239+
hint="It is suggested to keep REACTPY_AUTH_TOKEN_TIMEOUT under 120 seconds to prevent security risks.",
240+
id="reactpy_django.W020",
241+
)
242+
)
243+
244+
# Check if REACTPY_AUTH_TOKEN_TIMEOUT is a small value
245+
if isinstance(auth_token_timeout, int) and auth_token_timeout <= 2:
246+
warnings.append(
247+
Warning(
248+
"REACTPY_AUTH_TOKEN_TIMEOUT is set to a very low value.",
249+
hint="It is suggested to keep REACTPY_AUTH_TOKEN_TIMEOUT above 2 seconds to account for client and server latency.",
250+
id="reactpy_django.W021",
251+
)
252+
)
253+
233254
return warnings
234255

235256

@@ -513,4 +534,34 @@ def reactpy_errors(app_configs, **kwargs):
513534
)
514535
)
515536

537+
# Check if REACTPY_CLEAN_AUTH_TOKENS is a valid data type
538+
if not isinstance(config.REACTPY_CLEAN_AUTH_TOKENS, bool):
539+
errors.append(
540+
Error(
541+
"Invalid type for REACTPY_CLEAN_AUTH_TOKENS.",
542+
hint="REACTPY_CLEAN_AUTH_TOKENS should be a boolean.",
543+
id="reactpy_django.E027",
544+
)
545+
)
546+
547+
# Check if REACTPY_AUTH_TOKEN_TIMEOUT is a valid data type
548+
if not isinstance(config.REACTPY_AUTH_TOKEN_TIMEOUT, int):
549+
errors.append(
550+
Error(
551+
"Invalid type for REACTPY_AUTH_TOKEN_TIMEOUT.",
552+
hint="REACTPY_AUTH_TOKEN_TIMEOUT should be an integer.",
553+
id="reactpy_django.E028",
554+
)
555+
)
556+
557+
# Check if REACTPY_AUTH_TOKEN_TIMEOUT is a positive integer
558+
if isinstance(config.REACTPY_AUTH_TOKEN_TIMEOUT, int) and config.REACTPY_AUTH_TOKEN_TIMEOUT < 0:
559+
errors.append(
560+
Error(
561+
"Invalid value for REACTPY_AUTH_TOKEN_TIMEOUT.",
562+
hint="REACTPY_AUTH_TOKEN_TIMEOUT should be a non-negative integer.",
563+
id="reactpy_django.E029",
564+
)
565+
)
566+
516567
return errors

0 commit comments

Comments
 (0)