mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00

This class will handle the storing and processing of secrets. Such as tokens. It will try to use the system keyring by default. Falling back to less secure methods, if the user doesn't allow access to the keyring or if the back-end is unsupported. CURA-7180 keyring storage
20 lines
536 B
Python
20 lines
536 B
Python
import keyring
|
|
|
|
|
|
class SecretStorage:
|
|
def __init__(self):
|
|
self._stored_secrets = []
|
|
|
|
def __delitem__(self, key):
|
|
if key in self._stored_secrets:
|
|
del self._stored_secrets[key]
|
|
keyring.delete_password("cura", key)
|
|
|
|
def __setitem__(self, key, value):
|
|
self._stored_secrets.append(key)
|
|
keyring.set_password("cura", key, value)
|
|
|
|
def __getitem__(self, key):
|
|
if key in self._stored_secrets:
|
|
return keyring.get_password("cura", key)
|
|
return None
|