mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-11 16:00:47 -07:00
Added fundaments of SecretStorage vault
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
This commit is contained in:
parent
720b356221
commit
47df060bee
2 changed files with 27 additions and 4 deletions
20
cura/OAuth2/SecretStorage.py
Normal file
20
cura/OAuth2/SecretStorage.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue