mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
fix(backups): return type of encryption key
This commit is contained in:
parent
c603394449
commit
421c92d12e
|
@ -15,13 +15,13 @@ redis = RedisPool().get_connection()
|
||||||
|
|
||||||
class LocalBackupSecret:
|
class LocalBackupSecret:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get():
|
def get() -> str:
|
||||||
"""A secret string which backblaze/other clouds do not know.
|
"""A secret string which backblaze/other clouds do not know.
|
||||||
Serves as encryption key.
|
Serves as encryption key.
|
||||||
"""
|
"""
|
||||||
if not LocalBackupSecret.exists():
|
if not LocalBackupSecret.exists():
|
||||||
LocalBackupSecret.reset()
|
LocalBackupSecret.reset()
|
||||||
return redis.get(REDIS_KEY)
|
return redis.get(REDIS_KEY) # type: ignore
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set(secret: str):
|
def set(secret: str):
|
||||||
|
|
|
@ -12,6 +12,8 @@ class AbstractBackupProvider(ABC):
|
||||||
def backuper(self) -> AbstractBackuper:
|
def backuper(self) -> AbstractBackuper:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
name = "NONE"
|
||||||
|
|
||||||
def __init__(self, login="", key="", location="", repo_id=""):
|
def __init__(self, login="", key="", location="", repo_id=""):
|
||||||
self.backuper.set_creds(login, key, location)
|
self.backuper.set_creds(login, key, location)
|
||||||
self.login = login
|
self.login = login
|
||||||
|
|
|
@ -28,10 +28,9 @@ class BackupConfiguration:
|
||||||
class Backup:
|
class Backup:
|
||||||
@strawberry.field
|
@strawberry.field
|
||||||
def configuration(self) -> BackupConfiguration:
|
def configuration(self) -> BackupConfiguration:
|
||||||
encryption_key = LocalBackupSecret.get()
|
|
||||||
return BackupConfiguration(
|
return BackupConfiguration(
|
||||||
provider=BackupProvider[Backups.provider().name],
|
provider=BackupProvider[Backups.provider().name],
|
||||||
encryption_key=encryption_key.decode() if encryption_key else "",
|
encryption_key=LocalBackupSecret.get(),
|
||||||
is_initialized=Backups.is_initted(),
|
is_initialized=Backups.is_initted(),
|
||||||
autobackup_period=Backups.autobackup_period_minutes(),
|
autobackup_period=Backups.autobackup_period_minutes(),
|
||||||
location_name=Backups.provider().location,
|
location_name=Backups.provider().location,
|
||||||
|
|
Loading…
Reference in a new issue