mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 20:14:01 +03:00
Add a system check for WWW_AUTHENTICATE_BEHAVIOR setting
This commit is contained in:
parent
8c23de27e8
commit
525979e343
|
@ -8,3 +8,4 @@ class RestFrameworkConfig(AppConfig):
|
||||||
def ready(self):
|
def ready(self):
|
||||||
# Add System checks
|
# Add System checks
|
||||||
from .checks import pagination_system_check # NOQA
|
from .checks import pagination_system_check # NOQA
|
||||||
|
from .checks import www_authenticate_behavior_setting_check # NOQA
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.core.checks import Tags, Warning, register
|
from django.core.checks import Tags, Error, Warning, register
|
||||||
|
|
||||||
|
|
||||||
@register(Tags.compatibility)
|
@register(Tags.compatibility)
|
||||||
|
@ -19,3 +19,22 @@ def pagination_system_check(app_configs, **kwargs):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
||||||
|
@register(Tags.compatibility)
|
||||||
|
def www_authenticate_behavior_setting_check(app_configs, **kwargs):
|
||||||
|
errors = []
|
||||||
|
# WWW_AUTHENTICATE_BEHAVIOR setting must be 'first' or 'all'
|
||||||
|
from rest_framework.settings import api_settings
|
||||||
|
setting = api_settings.WWW_AUTHENTICATE_BEHAVIOR
|
||||||
|
if setting not in ['first', 'all']:
|
||||||
|
errors.append(
|
||||||
|
Error(
|
||||||
|
"The rest_framework setting WWW_AUTHENTICATE_BEHAVIOR must be either "
|
||||||
|
f"'first' or 'all' (it is currently set to '{setting}').",
|
||||||
|
hint="Set WWW_AUTHENTICATE_BEHAVIOR to either 'first' or 'all', "
|
||||||
|
"or leave it unset (the default value is 'first').",
|
||||||
|
id="rest_framework.E001",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return errors
|
||||||
|
|
Loading…
Reference in New Issue
Block a user