File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ class APIView(View):
107
107
renderer_classes = api_settings .DEFAULT_RENDERER_CLASSES
108
108
parser_classes = api_settings .DEFAULT_PARSER_CLASSES
109
109
authentication_classes = api_settings .DEFAULT_AUTHENTICATION_CLASSES
110
+ www_authenticate_behavior = api_settings .WWW_AUTHENTICATE_BEHAVIOR
110
111
throttle_classes = api_settings .DEFAULT_THROTTLE_CLASSES
111
112
permission_classes = api_settings .DEFAULT_PERMISSION_CLASSES
112
113
content_negotiation_class = api_settings .DEFAULT_CONTENT_NEGOTIATION_CLASS
@@ -186,8 +187,13 @@ def get_authenticate_header(self, request):
186
187
header to use for 401 responses, if any.
187
188
"""
188
189
authenticators = self .get_authenticators ()
190
+ www_authenticate_behavior = self .www_authenticate_behavior
189
191
if authenticators :
190
- return authenticators [0 ].authenticate_header (request )
192
+ if www_authenticate_behavior == 'first' :
193
+ return authenticators [0 ].authenticate_header (request )
194
+ elif www_authenticate_behavior == 'all' :
195
+ challenges = (a .authenticate_header (request ) for a in authenticators )
196
+ return ', ' .join ((c for c in challenges if c is not None ))
191
197
192
198
def get_parser_context (self , http_request ):
193
199
"""
You can’t perform that action at this time.
0 commit comments