|
|
@ -25,7 +25,7 @@ def hash_password(password, secret=None): |
|
|
|
secret = Secret() |
|
|
|
secret = Secret() |
|
|
|
h = pbkdf2_hmac('sha512', |
|
|
|
h = pbkdf2_hmac('sha512', |
|
|
|
password=password.encode('utf8'), |
|
|
|
password=password.encode('utf8'), |
|
|
|
salt=secret.encode('utf8'), |
|
|
|
salt=secret.key.encode('utf8'), |
|
|
|
iterations=250000) |
|
|
|
iterations=250000) |
|
|
|
return h.hex() |
|
|
|
return h.hex() |
|
|
|
|
|
|
|
|
|
|
@ -113,7 +113,6 @@ class LegacySettings: |
|
|
|
file = file.with_suffix('.bak') |
|
|
|
file = file.with_suffix('.bak') |
|
|
|
|
|
|
|
|
|
|
|
with file.open('r') as fp: |
|
|
|
with file.open('r') as fp: |
|
|
|
print(f"Loading old conf from {file}") |
|
|
|
|
|
|
|
conf = yaml.safe_load(fp) |
|
|
|
conf = yaml.safe_load(fp) |
|
|
|
|
|
|
|
|
|
|
|
self.system = conf['system'] |
|
|
|
self.system = conf['system'] |
|
|
@ -130,10 +129,10 @@ class LegacySettings: |
|
|
|
systemvars = { |
|
|
|
systemvars = { |
|
|
|
'system': { |
|
|
|
'system': { |
|
|
|
'weburl': self.system['web_url'], |
|
|
|
'weburl': self.system['web_url'], |
|
|
|
'cookie_domain': self.system['cookie-domain'], |
|
|
|
'cookie_domain': self.system['cookie_domain'], |
|
|
|
'database_uri': self.system['database_uri'], |
|
|
|
'database_uri': self.system['database_uri'], |
|
|
|
'debug': self.system['debug'], |
|
|
|
'debug': self.system['debug'], |
|
|
|
'cookie_secure': False |
|
|
|
'cookie_secure': self.system['cookie_secure'] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -149,7 +148,6 @@ class LegacySettings: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# backup old config |
|
|
|
# backup old config |
|
|
|
print("Copying old config to backup") |
|
|
|
|
|
|
|
copy(old, old.with_suffix('.bak')) |
|
|
|
copy(old, old.with_suffix('.bak')) |
|
|
|
|
|
|
|
|
|
|
|
# Write new config files |
|
|
|
# Write new config files |
|
|
@ -165,14 +163,10 @@ class LegacySettings: |
|
|
|
p_secret = '/etc/labertasche/' / p_secret |
|
|
|
p_secret = '/etc/labertasche/' / p_secret |
|
|
|
|
|
|
|
|
|
|
|
with p_sys.open('w') as fp: |
|
|
|
with p_sys.open('w') as fp: |
|
|
|
print("Dumping system vars as yaml") |
|
|
|
|
|
|
|
yaml.dump(systemvars, fp) |
|
|
|
yaml.dump(systemvars, fp) |
|
|
|
with p_credentials.open('w') as fp: |
|
|
|
with p_credentials.open('w') as fp: |
|
|
|
print("Dumping credentials as yaml") |
|
|
|
|
|
|
|
yaml.dump(credentials, fp) |
|
|
|
yaml.dump(credentials, fp) |
|
|
|
with p_smileys.open('w') as fp: |
|
|
|
with p_smileys.open('w') as fp: |
|
|
|
print("Dumping smileys as yaml") |
|
|
|
|
|
|
|
yaml.dump(smileys, fp) |
|
|
|
yaml.dump(smileys, fp) |
|
|
|
with p_secret.open('w') as fp: |
|
|
|
with p_secret.open('w') as fp: |
|
|
|
print("Dumping secret") |
|
|
|
|
|
|
|
fp.write(self.system['secret']) |
|
|
|
fp.write(self.system['secret']) |
|
|
|