Skip to content

Commit cc3a7e2

Browse files
committed
Add a system check for WWW_AUTHENTICATE_BEHAVIOR setting
1 parent 8c23de2 commit cc3a7e2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

rest_framework/checks.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.core.checks import Tags, Warning, register
1+
from django.core.checks import Tags, Error, Warning, register
22

33

44
@register(Tags.compatibility)
@@ -19,3 +19,22 @@ def pagination_system_check(app_configs, **kwargs):
1919
)
2020
)
2121
return errors
22+
23+
24+
@register(Tags.compatibility)
25+
def www_authneticate_behavior_setting_check(app_configs, **kwargs):
26+
errors = []
27+
# WWW_AUTHENTICATE_BEHAVIOR setting must be 'first' or 'all'
28+
from rest_framework.settings import api_settings
29+
setting = api_settings.WWW_AUTHENTICATE_BEHAVIOR
30+
if setting not in ['first', 'all']:
31+
errors.append(
32+
Error(
33+
"The rest_framework setting WWW_AUTHENTICATE_BEHAVIOR must be either "
34+
f"'first' or 'all' (it is currently set to '{setting}').",
35+
hint="Set WWW_AUTHENTICATE_BEHAVIOR to either 'first' or 'all', "
36+
"or leave it unset (the default value is 'first').",
37+
id="rest_framework.E001",
38+
)
39+
)
40+
return errors

0 commit comments

Comments
 (0)