]> git.ipfire.org Git - pbs.git/commitdiff
web: Replace authentication decorate with our custom version
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 15:07:50 +0000 (15:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 15:07:50 +0000 (15:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/builders.py
src/web/builds.py
src/web/distributions.py
src/web/jobs.py
src/web/mirrors.py
src/web/monitorings.py
src/web/repos.py
src/web/users.py

index 681e9b97ece0cc772a45a7441700a2112e710e2f..906ec170d26662f4e2b7c0462d1a80c4e1c1349f 100644 (file)
@@ -101,7 +101,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class CreateHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self):
                # Must be admin
                if not self.current_user.is_admin():
@@ -109,7 +109,7 @@ class CreateHandler(base.BaseHandler):
 
                self.render("builders/create.html")
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self):
                # Must be admin
                if not self.current_user.is_admin():
@@ -125,7 +125,7 @@ class CreateHandler(base.BaseHandler):
 
 
 class EditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, hostname):
                builder = await self.backend.builders.get_by_name(hostname)
                if not builder:
@@ -137,7 +137,7 @@ class EditHandler(base.BaseHandler):
 
                self.render("builders/edit.html", builder=builder)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, hostname):
                builder = self.backend.builders.get_by_name(hostname)
                if not builder:
@@ -159,7 +159,7 @@ class EditHandler(base.BaseHandler):
 
 
 class DeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, name):
                builder = self.backend.builders.get_by_name(name)
                if not builder:
@@ -171,7 +171,7 @@ class DeleteHandler(base.BaseHandler):
 
                self.render("builders/delete.html", builder=builder)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, hostname):
                builder = self.backend.builders.get_by_name(hostname)
                if not builder:
@@ -189,7 +189,7 @@ class DeleteHandler(base.BaseHandler):
 
 
 class StartHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, name):
                builder = self.backend.builders.get_by_name(name)
                if not builder:
@@ -205,7 +205,7 @@ class StartHandler(base.BaseHandler):
 
                self.render("builders/start.html", builder=builder)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, name):
                builder = self.backend.builders.get_by_name(name)
                if not builder:
@@ -231,7 +231,7 @@ class StartHandler(base.BaseHandler):
 
 
 class StopHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, name):
                builder = self.backend.builders.get_by_name(name)
                if not builder:
@@ -247,7 +247,7 @@ class StopHandler(base.BaseHandler):
 
                self.render("builders/stop.html", builder=builder)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, name):
                builder = self.backend.builders.get_by_name(name)
                if not builder:
index a4f0246ff838dda4d8a7dca2e6df03565fd9fa14..cc306aa2cf9392332f4789465a9414c8bac2370c 100644 (file)
@@ -105,7 +105,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class ApproveHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -117,7 +117,7 @@ class ApproveHandler(base.BaseHandler):
 
                self.render("builds/approve.html", build=build)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -135,7 +135,7 @@ class ApproveHandler(base.BaseHandler):
 
 
 class CloneHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -149,7 +149,7 @@ class CloneHandler(base.BaseHandler):
 
                self.render("builds/clone.html", build=build, repos=repos)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -171,7 +171,7 @@ class CloneHandler(base.BaseHandler):
 
 
 class DeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -184,7 +184,7 @@ class DeleteHandler(base.BaseHandler):
 
                self.render("builds/delete.html", build=build)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -203,7 +203,7 @@ class DeleteHandler(base.BaseHandler):
 
 
 class WatchHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -216,7 +216,7 @@ class WatchHandler(base.BaseHandler):
 
 
 class UnwatchHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -229,7 +229,7 @@ class UnwatchHandler(base.BaseHandler):
 
 
 class CommentHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -246,7 +246,7 @@ class CommentHandler(base.BaseHandler):
 
 
 class BugHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -257,7 +257,7 @@ class BugHandler(base.BaseHandler):
 
                self.render("builds/bug.html", build=build, fields=fields)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -297,7 +297,7 @@ class BugHandler(base.BaseHandler):
 
 
 class ReposAddHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -311,7 +311,7 @@ class ReposAddHandler(base.BaseHandler):
 
                self.render("builds/repos/add.html", build=build, repos=repos)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -332,7 +332,7 @@ class ReposAddHandler(base.BaseHandler):
 
 
 class ReposRemoveHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
@@ -344,7 +344,7 @@ class ReposRemoveHandler(base.BaseHandler):
 
                self.render("builds/repos/remove.html", build=build)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                build = self.backend.builds.get_by_uuid(uuid)
                if not build:
index 2e46c3f37fc4b10c838197ce0c263f97ff04cbf5..3bd4582c4143fd48b394b8b57a36f018bb243969 100644 (file)
@@ -21,7 +21,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class EditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, slug):
                distro = await self.backend.distros.get_by_slug(slug)
                if not distro:
@@ -36,7 +36,7 @@ class EditHandler(base.BaseHandler):
 
                self.render("distros/edit.html", distro=distro, bugzilla_products=bugzilla_products)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, slug):
                distro = await self.backend.distros.get_by_slug(slug)
                if not distro:
@@ -89,7 +89,7 @@ class ReleasesShowHandler(base.BaseHandler):
 
 
 class ReleasesCreateHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, distro_slug):
                distro = await self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -101,7 +101,7 @@ class ReleasesCreateHandler(base.BaseHandler):
 
                self.render("distros/releases/edit.html", release=None, distro=distro)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, distro_slug):
                distro = await self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -129,7 +129,7 @@ class ReleasesCreateHandler(base.BaseHandler):
 
 
 class ReleasesEditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -146,7 +146,7 @@ class ReleasesEditHandler(base.BaseHandler):
 
                self.render("distros/releases/edit.html", release=release, distro=distro)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -176,7 +176,7 @@ class ReleasesEditHandler(base.BaseHandler):
 
 
 class ReleasesDeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -193,7 +193,7 @@ class ReleasesDeleteHandler(base.BaseHandler):
 
                self.render("distros/releases/delete.html", release=release, distro=distro)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -216,7 +216,7 @@ class ReleasesDeleteHandler(base.BaseHandler):
 
 
 class ReleasesPublishHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
@@ -233,7 +233,7 @@ class ReleasesPublishHandler(base.BaseHandler):
 
                self.render("distros/releases/publish.html", release=release, distro=distro)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, distro_slug, release_slug):
                distro = self.backend.distros.get_by_slug(distro_slug)
                if not distro:
index a2e8f9a9472b2838858cf9cbd3c3070ba92cf1a2..1ed02b9189d6cdf52b1c6affd04a8ed2066e855e 100644 (file)
@@ -193,7 +193,7 @@ class LogHandler(base.BaseHandler):
 
 
 class AbortHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, uuid):
                job = await self.backend.jobs.get_by_uuid(uuid)
                if not job:
@@ -205,7 +205,7 @@ class AbortHandler(base.BaseHandler):
 
                self.render("jobs/abort.html", job=job)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                job = await self.backend.jobs.get_by_uuid(uuid)
                if not job:
@@ -222,7 +222,7 @@ class AbortHandler(base.BaseHandler):
 
 
 class RetryHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, uuid):
                job = await self.backend.jobs.get_by_uuid(uuid)
                if not job:
@@ -234,7 +234,7 @@ class RetryHandler(base.BaseHandler):
 
                self.render("jobs/retry.html", job=job)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, uuid):
                job = await self.backend.jobs.get_by_uuid(uuid)
                if not job:
index 272fd53f04ff17122a768b7acf98e532da274ccd..1e3773970307753869296f69cb259b618c584ab3 100644 (file)
@@ -20,7 +20,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class CheckHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, hostname):
                mirror = self.backend.mirrors.get_by_hostname(hostname)
                if not mirror:
@@ -44,11 +44,11 @@ class CreateHandler(base.BaseHandler):
                if not self.current_user.is_admin():
                        raise tornado.web.HTTPError(403)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self):
                self.render("mirrors/edit.html", mirror=None)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self):
                # Fetch all values
                hostname = self.get_argument("hostname")
@@ -72,7 +72,7 @@ class CreateHandler(base.BaseHandler):
 
 
 class EditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, hostname):
                mirror = self.backend.mirrors.get_by_hostname(hostname)
                if not mirror:
@@ -84,7 +84,7 @@ class EditHandler(base.BaseHandler):
 
                self.render("mirrors/edit.html", mirror=mirror)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, hostname):
                mirror = self.backend.mirrors.get_by_hostname(hostname)
                if not mirror:
@@ -103,7 +103,7 @@ class EditHandler(base.BaseHandler):
 
 
 class DeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, hostname):
                mirror = self.backend.mirrors.get_by_hostname(hostname)
                if not mirror:
@@ -115,7 +115,7 @@ class DeleteHandler(base.BaseHandler):
 
                self.render("mirrors/delete.html", mirror=mirror)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, hostname):
                mirror = self.backend.mirrors.get_by_hostname(hostname)
                if not mirror:
index f535450f5a4a3b6f88db7ac0e55f169546a65760..eb0ea3addec1a4b44f64842627632d656675f1c8 100644 (file)
@@ -39,7 +39,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class CreateHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def get(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -64,7 +64,7 @@ class CreateHandler(base.BaseHandler):
                self.render("monitorings/edit.html", monitoring=None, distro=distro, name=name,
                        projects=projects)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -105,7 +105,7 @@ class CreateHandler(base.BaseHandler):
 
 
 class EditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -123,7 +123,7 @@ class EditHandler(base.BaseHandler):
 
                self.render("monitorings/edit.html", monitoring=monitoring, distro=distro, name=name)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -146,7 +146,7 @@ class EditHandler(base.BaseHandler):
 
 
 class DeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -164,7 +164,7 @@ class DeleteHandler(base.BaseHandler):
 
                self.render("monitorings/delete.html", monitoring=monitoring)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
@@ -187,7 +187,7 @@ class DeleteHandler(base.BaseHandler):
 
 
 class CheckHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, slug, name):
                # Fetch the distribution
                distro = self.backend.distros.get_by_slug(slug)
index e2e50d745c1a5eb9a0bee71e2469d06603d96ee5..de6db88b2760ffc3baf5850ec7ce2ca23664269b 100644 (file)
@@ -151,7 +151,7 @@ class BuildsHandler(BaseHandler):
 
 
 class CreateCustomHandler(BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, user_slug):
                user = self.backend.users.get_by_name(user_slug)
                if not user:
@@ -163,7 +163,7 @@ class CreateCustomHandler(BaseHandler):
 
                self.render("repos/create-custom.html", user=user, distros=self.backend.distros)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, user_slug):
                user = self.backend.users.get_by_name(user_slug)
                if not user:
@@ -203,7 +203,7 @@ class ConfigHandler(BaseHandler):
 
 
 class EditHandler(BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, **kwargs):
                # Fetch the repository
                repo = self._get_repo(**kwargs)
@@ -214,7 +214,7 @@ class EditHandler(BaseHandler):
 
                self.render("repos/edit.html", repo=repo)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, **kwargs):
                # Fetch the repository
                repo = self._get_repo(**kwargs)
@@ -240,7 +240,7 @@ class EditHandler(BaseHandler):
 
 
 class DeleteHandler(BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, **kwargs):
                # Fetch the repository
                repo = self._get_repo(**kwargs)
@@ -251,7 +251,7 @@ class DeleteHandler(BaseHandler):
 
                self.render("repos/delete.html", repo=repo)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, **kwargs):
                # Fetch the repository
                repo = self._get_repo(**kwargs)
index 1d436200cb495cd8962f1abdfe4ac0d3896f127e..9c2fe6c109ab104ce9426f810473f2e955e2364e 100644 (file)
@@ -25,7 +25,7 @@ class ShowHandler(base.BaseHandler):
 
 
 class DeleteHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, name):
                user = self.backend.users.get_by_name(name)
                if not user:
@@ -37,7 +37,7 @@ class DeleteHandler(base.BaseHandler):
 
                self.render("users/delete.html", user=user)
 
-       @tornado.web.authenticated
+       @base.authenticated
        def post(self, name):
                user = self.backend.users.get_by_name(name)
                if not user:
@@ -54,7 +54,7 @@ class DeleteHandler(base.BaseHandler):
 
 
 class EditHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self, name):
                user = self.backend.users.get_by_name(name)
                if not user:
@@ -66,7 +66,7 @@ class EditHandler(base.BaseHandler):
 
                self.render("users/edit.html", user=user)
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self, name):
                user = self.backend.users.get_by_name(name)
                if not user:
@@ -95,11 +95,11 @@ class BuildsHandler(base.BaseHandler):
 
 
 class PushSubscribeHandler(base.BaseHandler):
-       @tornado.web.authenticated
+       @base.authenticated
        def get(self):
                self.render("users/subscribe.html")
 
-       @tornado.web.authenticated
+       @base.authenticated
        async def post(self):
                # The request body must be JSON
                if not self.request.headers.get("Content-Type") == "application/json":