File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ class APIView(View):
107107 renderer_classes = api_settings .DEFAULT_RENDERER_CLASSES
108108 parser_classes = api_settings .DEFAULT_PARSER_CLASSES
109109 authentication_classes = api_settings .DEFAULT_AUTHENTICATION_CLASSES
110+ www_authenticate_behavior = api_settings .WWW_AUTHENTICATE_BEHAVIOR
110111 throttle_classes = api_settings .DEFAULT_THROTTLE_CLASSES
111112 permission_classes = api_settings .DEFAULT_PERMISSION_CLASSES
112113 content_negotiation_class = api_settings .DEFAULT_CONTENT_NEGOTIATION_CLASS
@@ -186,8 +187,13 @@ def get_authenticate_header(self, request):
186187 header to use for 401 responses, if any.
187188 """
188189 authenticators = self .get_authenticators ()
190+ www_authenticate_behavior = self .www_authenticate_behavior
189191 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 ))
191197
192198 def get_parser_context (self , http_request ):
193199 """
You can’t perform that action at this time.
0 commit comments