memory: temporary dirty hack to fix the personnal key issue after the auth session expired
This commit is contained in:
parent
fe06c14303
commit
e018212fb4
1 changed files with 15 additions and 4 deletions
|
|
@ -152,7 +152,6 @@ class ProfileSessions(Sessions):
|
|||
raise exceptions.InternalError('profileGetUnique has been used but more than one session has been found!')
|
||||
return self.profileGet(ids[0], profile) if len(ids) == 1 else None # XXX: timeout might be reset
|
||||
|
||||
|
||||
def profileDelUnique(self, profile):
|
||||
"""Delete the unique session that is associated to the given profile.
|
||||
|
||||
|
|
@ -166,6 +165,18 @@ class ProfileSessions(Sessions):
|
|||
del self._sessions[ids[0]]
|
||||
|
||||
|
||||
class PasswordSessions(ProfileSessions):
|
||||
|
||||
# FIXME: temporary hack for the user personal key not to be lost. The session
|
||||
# must actually be purged and later, when the personal key is needed, the
|
||||
# profile password should be asked again in order to decrypt it.
|
||||
def __init__(self, timeout=None):
|
||||
ProfileSessions.__init__(self, timeout, resettable_timeout=False)
|
||||
|
||||
def _purgeSession(self, session_id):
|
||||
log.debug("FIXME: PasswordSessions should ask for the profile password after the session expired")
|
||||
|
||||
|
||||
# XXX: tmp update code, will be removed in the future
|
||||
# When you remove this, please add the default value for
|
||||
# 'local_dir' in sat.core.constants.Const.DEFAULT_CONFIG
|
||||
|
|
@ -202,7 +213,7 @@ class Memory(object):
|
|||
self._entities_cache = {} # XXX: keep presence/last resource/other data in cache
|
||||
# /!\ an entity is not necessarily in roster
|
||||
self.subscriptions = {}
|
||||
self.auth_sessions = ProfileSessions() # remember the authenticated profiles
|
||||
self.auth_sessions = PasswordSessions() # remember the authenticated profiles
|
||||
self.disco = Discovery(host)
|
||||
fixLocalDir(False) # XXX: tmp update code, will be removed in the future
|
||||
self.config = self.parseMainConf()
|
||||
|
|
@ -564,7 +575,7 @@ class Memory(object):
|
|||
@return: the deferred encrypted value
|
||||
"""
|
||||
try:
|
||||
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||
personal_key = self.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||
except TypeError:
|
||||
raise exceptions.InternalError(_('Trying to encrypt a value for %s while the personal key is undefined!') % profile)
|
||||
return BlockCipher.encrypt(personal_key, value)
|
||||
|
|
@ -579,7 +590,7 @@ class Memory(object):
|
|||
@return: the deferred decrypted value
|
||||
"""
|
||||
try:
|
||||
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||
personal_key = self.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
|
||||
except TypeError:
|
||||
raise exceptions.InternalError(_('Trying to decrypt a value for %s while the personal key is undefined!') % profile)
|
||||
return BlockCipher.decrypt(personal_key, value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue