initial exploratory work on sync

This commit is contained in:
azivner 2017-06-13 23:31:54 -04:00
parent 53aa563cdb
commit 415a5f58f1
2 changed files with 31 additions and 2 deletions

26
app.py
View file

@ -10,6 +10,11 @@ import random
import string
import configparser
import bcrypt
import requests
import json
import os
import binascii
import hashlib
from flask import render_template, redirect
@ -303,5 +308,24 @@ def load_user(user_id):
else:
return None
syncServerUrl = config['Sync']['sync-server-url']
syncServerUsername = config['Sync']['sync-server-username']
syncServerPassword = config['Sync']['sync-server-password']
nonce = binascii.hexlify(bytearray(os.urandom(32)))
print('Nonce: ' + nonce)
# SHA256(user + ":" + SHA256(user + ":" + password) + ":" + nonce) where SHA256 is a hex encoded value
auth = hashlib.sha256(syncServerUsername + ":" + hashlib.sha256(syncServerPassword + ":" + syncServerPassword).hexdigest() + ":" + nonce).hexdigest()
response = requests.post(syncServerUrl + "/login", json={
'user': syncServerUsername,
'nonce': nonce,
'auth': auth
})
print(response)
if __name__ == '__main__':
app.run(host='0.0.0.0')
app.run(host='0.0.0.0')

View file

@ -2,4 +2,9 @@
# Enter below credentials with with which you want to authenticate to Notecase web app
username=adam
# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
password-hash=$2b$12$jcbhRx6WRbCRogpCckH1hehWrHWgFaFYC3u3ebdVURJX36..fdAca
password-hash=$2b$12$jcbhRx6WRbCRogpCckH1hehWrHWgFaFYC3u3ebdVURJX36..fdAca
[Sync]
sync-server-url=http://localhost:57201
sync-server-username=syncuser
sync-server-password=password