mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
Cherry-pick supported python-keyring backends
Also provide pretty names and descriptions.
This commit is contained in:
parent
88a8a0cdd8
commit
8e0e0a9ca8
@ -195,16 +195,21 @@ class KeyringCredentialsManager(AbstractCredentialsManager):
|
|||||||
|
|
||||||
|
|
||||||
class KeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):
|
class KeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):
|
||||||
def __init__(self, keyring_backend):
|
def __init__(self, keyring_backend, name=None, description=None):
|
||||||
self._keyring_backend = keyring_backend
|
self._keyring_backend = keyring_backend
|
||||||
|
self._name = name
|
||||||
|
self._description = description
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
|
if self._name:
|
||||||
|
return self._name
|
||||||
if hasattr(self._keyring_backend, 'name'):
|
if hasattr(self._keyring_backend, 'name'):
|
||||||
return self._keyring_backend.name
|
return self._keyring_backend.name
|
||||||
else:
|
|
||||||
return self._keyring_backend.__class__.__name__
|
return self._keyring_backend.__class__.__name__
|
||||||
|
|
||||||
def description(self):
|
def description(self):
|
||||||
|
if self._description:
|
||||||
|
return self._description
|
||||||
return 'Backend provided by python-keyring'
|
return 'Backend provided by python-keyring'
|
||||||
|
|
||||||
def create(self, cp):
|
def create(self, cp):
|
||||||
@ -280,14 +285,34 @@ class GnomeKeyringCredentialsDescriptor(AbstractCredentialsManagerDescriptor):
|
|||||||
return GnomeKeyringCredentialsManager(cp, None)
|
return GnomeKeyringCredentialsManager(cp, None)
|
||||||
|
|
||||||
|
|
||||||
|
# we're supporting only selected python-keyring backends in osc
|
||||||
|
SUPPORTED_KEYRING_BACKENDS = {
|
||||||
|
"keyutils.osc.OscKernelKeyringBackend": {
|
||||||
|
"name": "Kernel keyring",
|
||||||
|
"description": "Store password in user session keyring in kernel keyring [secure, in-memory, per-session]",
|
||||||
|
},
|
||||||
|
"keyring.backends.SecretService.Keyring": {
|
||||||
|
"name": "Secret Service",
|
||||||
|
"description": "Store password in Secret Service (GNOME Keyring backend) [secure, persistent]",
|
||||||
|
},
|
||||||
|
"keyring.backends.kwallet.DBusKeyring": {
|
||||||
|
"name": "KWallet",
|
||||||
|
"description": "Store password in KWallet [secure, persistent]",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_credentials_manager_descriptors():
|
def get_credentials_manager_descriptors():
|
||||||
if has_keyring_support():
|
|
||||||
backend_list = keyring.backend.get_all_keyring()
|
|
||||||
else:
|
|
||||||
backend_list = []
|
|
||||||
descriptors = []
|
descriptors = []
|
||||||
for backend in backend_list:
|
|
||||||
descriptors.append(KeyringCredentialsDescriptor(backend))
|
if has_keyring_support():
|
||||||
|
for backend in keyring.backend.get_all_keyring():
|
||||||
|
qualified_backend_name = qualified_name(backend)
|
||||||
|
data = SUPPORTED_KEYRING_BACKENDS.get(qualified_backend_name, None)
|
||||||
|
if not data:
|
||||||
|
continue
|
||||||
|
descriptor = KeyringCredentialsDescriptor(backend, data["name"], data["description"])
|
||||||
|
descriptors.append(descriptor)
|
||||||
descriptors.sort()
|
descriptors.sort()
|
||||||
if gnomekeyring:
|
if gnomekeyring:
|
||||||
descriptors.append(GnomeKeyringCredentialsDescriptor())
|
descriptors.append(GnomeKeyringCredentialsDescriptor())
|
||||||
|
Loading…
Reference in New Issue
Block a user