mirror of https://github.com/TriliumNext/Notes
username, password and flask_secret_key are now persisted in database
parent
9787ce432a
commit
b4f9fc3a5e
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import getpass
|
||||
import src.my_scrypt
|
||||
import binascii
|
||||
import src.password_provider
|
||||
|
||||
password1 = getpass.getpass()
|
||||
password2 = getpass.getpass(prompt='Repeat the same password:')
|
||||
|
||||
if password1 == password2:
|
||||
hash = src.my_scrypt.getVerificationHash(password1)
|
||||
|
||||
src.password_provider.setPasswordHash(binascii.hexlify(hash))
|
||||
|
||||
print('Password has been generated and saved into password.txt. You can now login.')
|
||||
else:
|
||||
print('Entered passwords are not identical!')
|
||||
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import base64
|
||||
|
||||
print(base64.b64encode(os.urandom(24)))
|
||||
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import binascii
|
||||
import getpass
|
||||
import os
|
||||
import base64
|
||||
|
||||
from builtins import input
|
||||
|
||||
import src.config_provider
|
||||
import src.sql
|
||||
import src.my_scrypt
|
||||
|
||||
config = src.config_provider.getConfig()
|
||||
src.sql.connect(config['Document']['documentPath'])
|
||||
|
||||
username = src.sql.getOption("username")
|
||||
|
||||
if username:
|
||||
print("Application has been already set up.")
|
||||
exit(1)
|
||||
|
||||
print("Please provide your desired login credentials")
|
||||
|
||||
username = input("Username: ")
|
||||
|
||||
password1 = getpass.getpass()
|
||||
password2 = getpass.getpass(prompt='Repeat the same password: ')
|
||||
|
||||
if password1 == password2:
|
||||
hash = src.my_scrypt.getVerificationHash(password1)
|
||||
|
||||
src.sql.setOption('username', username)
|
||||
src.sql.setOption('password', binascii.hexlify(hash))
|
||||
|
||||
# urandom is secure enough, see https://docs.python.org/2/library/os.html
|
||||
src.sql.setOption('flask_secret_key', base64.b64encode(os.urandom(24)))
|
||||
src.sql.setOption('verification_salt', base64.b64encode(os.urandom(24)))
|
||||
src.sql.setOption('encryption_salt', base64.b64encode(os.urandom(24)))
|
||||
|
||||
src.sql.commit()
|
||||
|
||||
print('Application has been set up. You can now login.')
|
||||
else:
|
||||
print('Entered passwords are not identical!')
|
||||
@ -1,7 +0,0 @@
|
||||
def getPasswordHash():
|
||||
with open('password.txt') as file:
|
||||
return file.readline()
|
||||
|
||||
def setPasswordHash(newPasswordHash):
|
||||
with open('password.txt', 'w') as file:
|
||||
file.write(newPasswordHash)
|
||||
Loading…
Reference in New Issue