@@ -287,6 +287,66 @@ func TestProxyController(t *testing.T) {
287287 assert .Equal (t , http .StatusOK , recorder .Code )
288288 },
289289 },
290+ {
291+ description : "Ensure path allow ACL does not match forwarded URI query string" ,
292+ middlewares : []gin.HandlerFunc {},
293+ run : func (t * testing.T , router * gin.Engine , recorder * httptest.ResponseRecorder ) {
294+ req := httptest .NewRequest ("GET" , "/api/auth/traefik" , nil )
295+ req .Header .Set ("x-forwarded-host" , "path-allow.example.com" )
296+ req .Header .Set ("x-forwarded-proto" , "https" )
297+ req .Header .Set ("x-forwarded-uri" , "/admin?path=/allowed" )
298+ router .ServeHTTP (recorder , req )
299+ assert .Equal (t , http .StatusUnauthorized , recorder .Code )
300+ },
301+ },
302+ {
303+ description : "Ensure path allow ACL does not match path substrings" ,
304+ middlewares : []gin.HandlerFunc {},
305+ run : func (t * testing.T , router * gin.Engine , recorder * httptest.ResponseRecorder ) {
306+ req := httptest .NewRequest ("GET" , "/api/auth/traefik" , nil )
307+ req .Header .Set ("x-forwarded-host" , "path-allow.example.com" )
308+ req .Header .Set ("x-forwarded-proto" , "https" )
309+ req .Header .Set ("x-forwarded-uri" , "/admin/allowed" )
310+ router .ServeHTTP (recorder , req )
311+ assert .Equal (t , http .StatusUnauthorized , recorder .Code )
312+ },
313+ },
314+ {
315+ description : "Ensure path block ACL works on forward auth" ,
316+ middlewares : []gin.HandlerFunc {},
317+ run : func (t * testing.T , router * gin.Engine , recorder * httptest.ResponseRecorder ) {
318+ req := httptest .NewRequest ("GET" , "/api/auth/traefik" , nil )
319+ req .Header .Set ("x-forwarded-host" , "path-block.example.com" )
320+ req .Header .Set ("x-forwarded-proto" , "https" )
321+ req .Header .Set ("x-forwarded-uri" , "/blocked" )
322+ router .ServeHTTP (recorder , req )
323+ assert .Equal (t , http .StatusUnauthorized , recorder .Code )
324+ },
325+ },
326+ {
327+ description : "Ensure path block ACL does not match forwarded URI query string" ,
328+ middlewares : []gin.HandlerFunc {},
329+ run : func (t * testing.T , router * gin.Engine , recorder * httptest.ResponseRecorder ) {
330+ req := httptest .NewRequest ("GET" , "/api/auth/traefik" , nil )
331+ req .Header .Set ("x-forwarded-host" , "path-block.example.com" )
332+ req .Header .Set ("x-forwarded-proto" , "https" )
333+ req .Header .Set ("x-forwarded-uri" , "/admin?path=/blocked" )
334+ router .ServeHTTP (recorder , req )
335+ assert .Equal (t , http .StatusOK , recorder .Code )
336+ },
337+ },
338+ {
339+ description : "Ensure path block ACL does not match path substrings" ,
340+ middlewares : []gin.HandlerFunc {},
341+ run : func (t * testing.T , router * gin.Engine , recorder * httptest.ResponseRecorder ) {
342+ req := httptest .NewRequest ("GET" , "/api/auth/traefik" , nil )
343+ req .Header .Set ("x-forwarded-host" , "path-block.example.com" )
344+ req .Header .Set ("x-forwarded-proto" , "https" )
345+ req .Header .Set ("x-forwarded-uri" , "/admin/blocked" )
346+ router .ServeHTTP (recorder , req )
347+ assert .Equal (t , http .StatusOK , recorder .Code )
348+ },
349+ },
290350 {
291351 description : "Ensure path allow ACL works on nginx auth request" ,
292352 middlewares : []gin.HandlerFunc {},
0 commit comments