Skip to content

Commit

Permalink
Merge branch 'master' into csauth
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr committed Apr 16, 2015
2 parents 27b757a + d2fefed commit b671d3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sydent/sign/ed25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def __init__(self, syd):
skHex = self.sydent.cfg.get('crypto', 'ed25519.signingkey')
if skHex != '':
self.signing_key = nacl.signing.SigningKey(skHex, encoder=nacl.encoding.HexEncoder)
self.signing_key.version = '0' # temp fix for API change
else:
logger.info("This server does not yet have an ed25519 signing key. "+
"Creating one and saving it in the config file.")

self.signing_key = nacl.signing.SigningKey.generate()
self.signing_key.version = '0' # temp fix for api change
skHex = self.signing_key.encode(encoder=nacl.encoding.HexEncoder)
self.sydent.cfg.set('crypto', 'ed25519.signingkey', skHex)
self.sydent.save_config()
5 changes: 5 additions & 0 deletions sydent/validators/emailvalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,28 @@ def validateSessionWithToken(self, sid, clientSecret, token):
valSessionStore = ThreePidValSessionStore(self.sydent)
s = valSessionStore.getTokenSessionById(sid)
if not s:
logger.info("Session ID %s not found", (sid))
return False

if not clientSecret == s.clientSecret:
logger.info("Incorrect client secret", (sid))
raise IncorrectClientSecretException()

if s.mtime + ValidationSession.THREEPID_SESSION_VALIDATION_TIMEOUT < time_msec():
logger.info("Session expired")
raise SessionExpiredException()

# TODO once we can validate the token oob
#if tokenObj.validated and clientSecret == tokenObj.clientSecret:
# return True

if s.token == token:
logger.info("Setting session %s as validated", (s.id))
valSessionStore.setValidated(s.id, True)

return {'success': True}
else:
logger.info("Incorrect token submitted")
return False


Expand Down

0 comments on commit b671d3b

Please sign in to comment.