mirror of
https://github.com/zadam/trilium.git
synced 2024-11-10 17:13:45 +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
26
app.py
26
app.py
|
@ -10,6 +10,11 @@ import random
|
||||||
import string
|
import string
|
||||||
import configparser
|
import configparser
|
||||||
import bcrypt
|
import bcrypt
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import binascii
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from flask import render_template, redirect
|
from flask import render_template, redirect
|
||||||
|
|
||||||
|
@ -303,5 +308,24 @@ def load_user(user_id):
|
||||||
else:
|
else:
|
||||||
return None
|
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__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0')
|
app.run(host='0.0.0.0')
|
|
@ -2,4 +2,9 @@
|
||||||
# Enter below credentials with with which you want to authenticate to Notecase web app
|
# Enter below credentials with with which you want to authenticate to Notecase web app
|
||||||
username=adam
|
username=adam
|
||||||
# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
|
# 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
|
Loading…
Reference in a new issue