File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1182,13 +1182,19 @@ def _auth_get_original_url(self, request):
1182
1182
to let this request go through (by returning a 200 code) or if we block it (by returning
1183
1183
a 403 error). Note that we return 403 errors without any further details for security
1184
1184
reasons.
1185
+
1186
+ Traefik and other ingresses that aren't nginx don't send HTTP_X_ORIGINAL_URL but all
1187
+ should send the standard X-Forwarded-* headers, fallback to that when HTTP_X_ORIGINAL_URL
1188
+ is not found.
1185
1189
"""
1186
1190
# Extract the original URL from the request header
1187
1191
original_url = request .META .get ("HTTP_X_ORIGINAL_URL" )
1188
1192
if not original_url :
1189
- logger .debug ("Missing HTTP_X_ORIGINAL_URL header in subrequest" )
1190
- raise drf .exceptions .PermissionDenied ()
1191
-
1193
+ logger .debug ( request .META )
1194
+ if not request .META .get ("HTTP_X_FORWARDED_URI" ):
1195
+ logger .debug ("Missing HTTP_X_ORIGINAL_URL header and HTTP_X_FORWARDED_URI http header." )
1196
+ raise drf .exceptions .PermissionDenied ()
1197
+ original_url = request .META .get ("HTTP_X_FORWARDED_PROTO" ) + "://" + request .META .get ("HTTP_X_FORWARDED_HOST" ) + request .META .get ("HTTP_X_FORWARDED_URI" )
1192
1198
logger .debug ("Original url: '%s'" , original_url )
1193
1199
return urlparse (original_url )
1194
1200
You can’t perform that action at this time.
0 commit comments