From: Michael Tremer Date: Tue, 21 Jan 2025 15:07:50 +0000 (+0000) Subject: web: Replace authentication decorate with our custom version X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7ee90e8e9d1ef4d0e50336748a5eb043dbac7a8;p=pbs.git web: Replace authentication decorate with our custom version Signed-off-by: Michael Tremer --- diff --git a/src/web/builders.py b/src/web/builders.py index 681e9b97..906ec170 100644 --- a/src/web/builders.py +++ b/src/web/builders.py @@ -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: diff --git a/src/web/builds.py b/src/web/builds.py index a4f0246f..cc306aa2 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -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: diff --git a/src/web/distributions.py b/src/web/distributions.py index 2e46c3f3..3bd4582c 100644 --- a/src/web/distributions.py +++ b/src/web/distributions.py @@ -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: diff --git a/src/web/jobs.py b/src/web/jobs.py index a2e8f9a9..1ed02b91 100644 --- a/src/web/jobs.py +++ b/src/web/jobs.py @@ -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: diff --git a/src/web/mirrors.py b/src/web/mirrors.py index 272fd53f..1e377397 100644 --- a/src/web/mirrors.py +++ b/src/web/mirrors.py @@ -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: diff --git a/src/web/monitorings.py b/src/web/monitorings.py index f535450f..eb0ea3ad 100644 --- a/src/web/monitorings.py +++ b/src/web/monitorings.py @@ -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) diff --git a/src/web/repos.py b/src/web/repos.py index e2e50d74..de6db88b 100644 --- a/src/web/repos.py +++ b/src/web/repos.py @@ -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) diff --git a/src/web/users.py b/src/web/users.py index 1d436200..9c2fe6c1 100644 --- a/src/web/users.py +++ b/src/web/users.py @@ -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":