From: Michael Tremer Date: Sun, 16 Apr 2023 10:36:09 +0000 (+0000) Subject: web: Fix access to other domains in dev environments X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c85f80e25e339ea0b1532ed6aed75cdfb3ac899c;p=ipfire.org.git web: Fix access to other domains in dev environments The former regular expression was slightly too greedy and this change should fix this. Signed-off-by: Michael Tremer --- diff --git a/src/web/__init__.py b/src/web/__init__.py index 8254593c..dfab444b 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -110,7 +110,7 @@ class Application(tornado.web.Application): (r"/logout", auth.LogoutHandler), ] - self.add_handlers(r"(www\.)?(.*)ipfire\.org", [ + self.add_handlers(r"(www\.)?([a-z]+\.dev\.)?ipfire\.org", [ # Entry site that lead the user to index (r"/", IndexHandler), (r"/about", AboutHandler), @@ -165,7 +165,7 @@ class Application(tornado.web.Application): ]) # blog.ipfire.org - LEGACY REDIRECTION - self.add_handlers(r"blog\.(.*)ipfire\.org", [ + self.add_handlers(r"blog\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/blog" }), (r"/authors/(\w+)", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/blog/authors/{0}" }), (r"/post/([0-9a-z\-\._]+)", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/blog/{0}" }), @@ -176,20 +176,20 @@ class Application(tornado.web.Application): ]) # downloads.ipfire.org - self.add_handlers(r"downloads\.(.*)ipfire\.org", [ + self.add_handlers(r"downloads\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download" }), (r"/release/(.*)", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download/{0}" }), (r"/(.*)", download.FileHandler), ]) # mirrors.ipfire.org - self.add_handlers(r"mirrors\.(.*)ipfire\.org", [ + self.add_handlers(r"mirrors\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download/mirrors" }), (r"/mirrors/(.*)", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download/mirrors/{0}" }), ]) # planet.ipfire.org - self.add_handlers(r"planet\.(.*)ipfire\.org", [ + self.add_handlers(r"planet\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://blog.ipfire.org/" }), (r"/post/([A-Za-z0-9_-]+)", handlers.PlanetPostHandler), (r"/user/([a-z0-9_-]+)", handlers.PlanetUserHandler), @@ -201,7 +201,7 @@ class Application(tornado.web.Application): ]) # fireinfo.ipfire.org - self.add_handlers(r"fireinfo\.(.*)ipfire\.org", [ + self.add_handlers(r"fireinfo\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", fireinfo.IndexHandler), # Admin @@ -230,14 +230,14 @@ class Application(tornado.web.Application): ] + authentication_handlers) # i-use.ipfire.org - self.add_handlers(r"i-use\.(.*)ipfire\.org", [ + self.add_handlers(r"i-use\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/" }), (r"/profile/([a-f0-9]{40})/([0-9]+).png", iuse.ImageHandler), ]) # boot.ipfire.org BOOT_STATIC_PATH = os.path.join(self.settings["static_path"], "netboot") - self.add_handlers(r"boot\.(.*)ipfire\.org", [ + self.add_handlers(r"boot\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://wiki.ipfire.org/installation/pxe" }), # Configurations @@ -251,7 +251,7 @@ class Application(tornado.web.Application): ]) # nopaste.ipfire.org - self.add_handlers(r"nopaste\.(.*)ipfire\.org", [ + self.add_handlers(r"nopaste\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", nopaste.CreateHandler), (r"/raw/(.*)", nopaste.RawHandler), (r"/view/(.*)", nopaste.ViewHandler), @@ -261,7 +261,7 @@ class Application(tornado.web.Application): ] + authentication_handlers) # location.ipfire.org - self.add_handlers(r"location\.(.*)ipfire\.org", [ + self.add_handlers(r"location\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", location.IndexHandler), (r"/download", StaticHandler, { "template" : "../location/download.html" }), (r"/how\-to\-use", StaticHandler, { "template" : "../location/how-to-use.html" }), @@ -273,17 +273,17 @@ class Application(tornado.web.Application): ]) # geoip.ipfire.org - self.add_handlers(r"geoip\.(.*)ipfire\.org", [ + self.add_handlers(r"geoip\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://location.ipfire.org/" }), ]) # talk.ipfire.org - self.add_handlers(r"talk\.(.*)ipfire\.org", [ + self.add_handlers(r"talk\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", tornado.web.RedirectHandler, { "url" : "https://people.ipfire.org/" }), ]) # people.ipfire.org - self.add_handlers(r"people\.(.*)ipfire\.org", [ + self.add_handlers(r"people\.([a-z]+\.dev\.)?ipfire\.org", [ (r"/", people.IndexHandler), (r"/activate/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.ActivateHandler), (r"/conferences", people.ConferencesHandler), @@ -323,7 +323,7 @@ class Application(tornado.web.Application): ] + authentication_handlers) # wiki.ipfire.org - self.add_handlers(r"wiki\.(.*)ipfire\.org", + self.add_handlers(r"wiki\.([a-z]+\.dev\.)?ipfire\.org", authentication_handlers + [ # Actions