def create_builds(self):
return self.data.create_builds
+ # Permissions
+
+ def has_perm(self, user=None):
+ # Anonymous users can't perform any actions
+ if user is None:
+ return False
+
+ # Users must be admins
+ return user.is_admin()
+
# Check
async def check(self):
class CheckHandler(base.BaseHandler):
+ @tornado.web.authenticated
async def post(self, slug, name):
# Fetch the distribution
distro = self.backend.distros.get_by_slug(slug)
if not monitoring:
raise tornado.web.HTTPError(404, "Could not find monitoring for %s in %s" % (name, distro))
+ # Check permissions
+ if not monitoring.has_perm(self.current_user):
+ raise tornado.web.HTTPError(403)
+
# Perform check
with self.db.transaction():
await monitoring.check()