mirror of
https://github.com/zadam/trilium.git
synced 2025-01-31 11:32:30 +08:00
initial exploratory work on sync
This commit is contained in:
parent
53aa563cdb
commit
415a5f58f1
2 changed files with 31 additions and 2 deletions
24
app.py
24
app.py
|
@ -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')
|
|
@ -3,3 +3,8 @@
|
|||
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
|
||||
|
||||
[Sync]
|
||||
sync-server-url=http://localhost:57201
|
||||
sync-server-username=syncuser
|
||||
sync-server-password=password
|
Loading…
Reference in a new issue