Merge lp:~nosferato/encuentro/keyring-fix into lp:encuentro

Proposed by Nicolas Guerrero
Status: Needs review
Proposed branch: lp:~nosferato/encuentro/keyring-fix
Merge into: lp:encuentro
Diff against target: 50 lines (+20/-1)
1 file modified
encuentro/config.py (+20/-1)
To merge this branch: bzr merge lp:~nosferato/encuentro/keyring-fix
Reviewer Review Type Date Requested Status
Facundo Batista Needs Fixing
Review via email: mp+258683@code.launchpad.net

Description of the change

I made some changes on config.py module in order to provide a keyring mask for user and password data.

To post a comment you must log in.
lp:~nosferato/encuentro/keyring-fix updated
255. By Nicolas Guerrero

keyring fix, last changes

Revision history for this message
Facundo Batista (facundo) wrote :

Discussed several details to fix on IRC

review: Needs Fixing

Unmerged revisions

255. By Nicolas Guerrero

keyring fix, last changes

254. By Nicolas Guerrero

Bug #1185528 -
The password should be saved in a safe keyring, if available, not in the config file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'encuentro/config.py'
2--- encuentro/config.py 2014-09-11 23:37:49 +0000
3+++ encuentro/config.py 2015-05-11 14:24:46 +0000
4@@ -18,6 +18,18 @@
5
6 """The system configuration."""
7
8+NOT_KEYRING_MSG = u"""
9+ATENCIÓN: no se encontró el módulo 'keyring'.
10+Si lo instala, Encuentro lo usará para guardar información
11+sensible (en lugar de guardarla en el archivo de configuración).
12+"""
13+
14+try:
15+ import keyring
16+except ImportError:
17+ keyring = None
18+ print NOT_KEYRING_MSG
19+
20 import logging
21 import os
22 import pickle
23@@ -61,6 +73,10 @@
24
25 with open(fname, 'rb') as fh:
26 saved_dict = pickle.load(fh)
27+ if keyring is not None:
28+ for key in SECURITY_CONFIG:
29+ if keyring.get_keyring() is not None:
30+ saved_dict[key] = keyring.get_password('encuentro', key)
31 logger.debug("Loaded: %s", self.sanitized_config())
32 self.update(saved_dict)
33
34@@ -72,6 +88,9 @@
35 """Save the config to disk."""
36 # we don't want to pickle this class, but the dict itself
37 raw_dict = self.copy()
38+ if keyring is not None:
39+ for key in SECURITY_CONFIG:
40+ keyring.set_password('encuentro', key,raw_dict.pop(key))
41 logger.debug("Saving: %s", self.sanitized_config())
42 with utils.SafeSaver(self._fname) as fh:
43 pickle.dump(raw_dict, fh)
44@@ -98,4 +117,4 @@
45
46
47 config = _Config()
48-signal = _Signal()
49+signal = _Signal()
50\ No newline at end of file

Subscribers

People subscribed via source and target branches