From: Michael Tremer Date: Thu, 23 Jan 2025 11:38:30 +0000 (+0000) Subject: users: Read the VAPID keys from the configuration file X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=119843950ba42d3a8f26e20daf94e03bfc4793b4;p=pbs.git users: Read the VAPID keys from the configuration file Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index e1332249..0c779768 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -97,7 +97,6 @@ class Backend(object): def launch_background_tasks(self): # Launch some initial tasks - #self.run_task(self.users.generate_vapid_keys) #self.run_task(self.builders.autoscale) # Regularly sync data to the mirrors diff --git a/src/buildservice/users.py b/src/buildservice/users.py index 60eef4cc..b26bcb49 100644 --- a/src/buildservice/users.py +++ b/src/buildservice/users.py @@ -446,50 +446,16 @@ class Users(base.Object): """ The public part of the VAPID key """ - return self.settings.get("vapid-public-key") + return self.config.get("vapid", "public-key") @property def vapid_private_key(self): """ The private part of the VAPID key """ - return self.settings.get("vapid-private-key") + return self.config.get("vapid", "private-key") - async def generate_vapid_keys(self): - """ - Generates the VAPID keys - """ - # Do not generate a new key if one exists - if self.vapid_public_key and self.vapid_private_key: - return - - with self.db.transaction(): - # Generate the private key - private_key = await self.backend.command( - "openssl", - "ecparam", - "-name", "prime256v1", - "-genkey", - "-noout", - return_output=True, - ) - - # Generate the public key - public_key = await self.backend.command( - "openssl", - "ec", - "-pubout", - input=private_key, - return_output=True, - ) - - # Store the keys - self.settings.set("vapid-public-key", public_key) - self.settings.set("vapid-private-key", private_key) - - log.info("VAPID keys have been successfully generated") - - @property + @functools.cached_property def application_server_key(self): lines = []