##// END OF EJS Templates
build new Session auth when either key or scheme changes
MinRK -
Show More
@@ -307,11 +307,8 b' class Session(Configurable):'
307
307
308 key = CBytes(b'', config=True,
308 key = CBytes(b'', config=True,
309 help="""execution key, for extra authentication.""")
309 help="""execution key, for extra authentication.""")
310 def _key_changed(self, name, old, new):
310 def _key_changed(self):
311 if new:
311 self._new_auth()
312 self.auth = hmac.HMAC(new, digestmod=self.digest_mod)
313 else:
314 self.auth = None
315
312
316 signature_scheme = Unicode('hmac-sha256', config=True,
313 signature_scheme = Unicode('hmac-sha256', config=True,
317 help="""The digest scheme used to construct the message signatures.
314 help="""The digest scheme used to construct the message signatures.
@@ -324,6 +321,7 b' class Session(Configurable):'
324 self.digest_mod = getattr(hashlib, hash_name)
321 self.digest_mod = getattr(hashlib, hash_name)
325 except AttributeError:
322 except AttributeError:
326 raise TraitError("hashlib has no such attribute: %s" % hash_name)
323 raise TraitError("hashlib has no such attribute: %s" % hash_name)
324 self._new_auth()
327
325
328 digest_mod = Any()
326 digest_mod = Any()
329 def _digest_mod_default(self):
327 def _digest_mod_default(self):
@@ -331,6 +329,12 b' class Session(Configurable):'
331
329
332 auth = Instance(hmac.HMAC)
330 auth = Instance(hmac.HMAC)
333
331
332 def _new_auth(self):
333 if self.key:
334 self.auth = hmac.HMAC(self.key, digestmod=self.digest_mod)
335 else:
336 self.auth = None
337
334 digest_history = Set()
338 digest_history = Set()
335 digest_history_size = Integer(2**16, config=True,
339 digest_history_size = Integer(2**16, config=True,
336 help="""The maximum number of digests to remember.
340 help="""The maximum number of digests to remember.
General Comments 0
You need to be logged in to leave comments. Login now