Missing version field on secrets file
Some of our users are getting a problem when trying to log in. Their secrets file don't have the version field.
Here is the secrets structure of those users:
{
"active_secret": "user_id",
"storage_secrets": {
"user_id": {
"kdf": "...",
"secret": "...",
"length": 1,
"cipher": "...",
"kdf_salt": "...",
"kdf_length": 1
}
}
}
It seems the structure have changed recently. This is the structure of users without problems:
{
"length": 1,
"version": 2,
"kdf_salt": "...",
"secrets": "...",
"kdf": "...",
"kdf_length": 1,
"cipher": 2,
"iv": "..."
}
Traceback:
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: 2017-03-09 18:51:13 [leap.soledad.client._secrets.storage] INFO secrets loaded successfully from disk
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: 2017-03-09 18:51:13 [twisted.web.client._HTTP11ClientFactory] INFO Stopping factory <twisted.web.client._HTTP11ClientFactory instance at 0x7f6c84498998>
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: 2017-03-09 18:51:13 [pixelated.config.leap] WARN TypeError: %d format: a number is required, not NoneType. Closing session for user: tuliocasagrande
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: 2017-03-09 18:51:13 [pixelated.resources.login_resource] ERROR Login error during tuliocasagrande services setup: %d format: a number is required, not NoneType
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: Traceback (most recent call last):
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: self._startRunCallbacks(fail)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: self._runCallbacks()
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: current.result = callback(current.result, *args, **kw)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1184, in gotResult
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: _inlineCallbacks(r, g, deferred)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: --- <exception caught here> ---
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = result.throwExceptionIntoGenerator(g)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return g.throw(self.type, self.value, self.tb)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/pixelated_user_agent-0.1-py2.7.egg/pixelated/config/leap.py", line 95, in setup
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: leap_session = yield create_leap_session(self._provider, user_auth.username, password, user_auth)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = result.throwExceptionIntoGenerator(g)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return g.throw(self.type, self.value, self.tb)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/pixelated_user_agent-0.1-py2.7.egg/pixelated/config/leap.py", line 57, in create_leap_session
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: leap_session = yield LeapSessionFactory(provider).create(username, password, auth)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = result.throwExceptionIntoGenerator(g)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return g.throw(self.type, self.value, self.tb)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/pixelated_user_agent-0.1-py2.7.egg/pixelated/config/sessions.py", line 53, in create
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: session = yield self._create_new_session(username, password, auth)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = result.throwExceptionIntoGenerator(g)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return g.throw(self.type, self.value, self.tb)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/pixelated_user_agent-0.1-py2.7.egg/pixelated/config/sessions.py", line 66, in _create_new_session
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: soledad = yield self.setup_soledad(auth.token, auth.uuid, password, api_cert)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in _inlineCallbacks
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = result.throwExceptionIntoGenerator(g)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return g.throw(self.type, self.value, self.tb)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/pixelated_user_agent-0.1-py2.7.egg/pixelated/config/sessions.py", line 98, in setup_soledad
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: auth_token=user_token)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 246, in inContext
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: result = inContext.theWork()
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 262, in <lambda>
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return self.currentContext().callWithContext(ctx, func, *args, **kw)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: return func(*args,**kw)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/src/leap.soledad.client/client/src/leap/soledad/client/api.py", line 198, in __init__
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: self._secrets = Secrets(self)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/src/leap.soledad.client/client/src/leap/soledad/client/_secrets/__init__.py", line 44, in __init__
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: self._bootstrap()
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/src/leap.soledad.client/client/src/leap/soledad/client/_secrets/__init__.py", line 55, in _bootstrap
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: self._secrets = self.crypto.decrypt(encrypted)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: File "/usr/share/python/pixelated-user-agent/src/leap.soledad.client/client/src/leap/soledad/client/_secrets/crypto.py", line 76, in decrypt
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: method = getattr(self, '_decrypt_v%d' % version)
Mar 9 18:51:13 pixelated pixelated-user-agent[16988]: exceptions.TypeError: %d format: a number is required, not NoneType
It seems the default value is missing, like this:
version = data.get('version', 1)
At this file: client/src/leap/soledad/client/_secrets/crypto.py#L75.