1
0
mirror of https://git.osuv.de/m/gitea-mariadb-migration.git synced 2024-05-12 03:55:05 +00:00

finish migration script

This commit is contained in:
Markus Bergholz
2018-08-22 13:24:53 +02:00
parent 9e94d0aa57
commit 257fac1e96

View File

@ -2,7 +2,12 @@
import sqlite3
import os
import MariaSQL
import hashlib
import binascii
import random
def GetRandomString(N):
return ''.join(random.choice("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") for _ in range(10))
def dict_factory(cursor, row):
d = {}
@ -74,4 +79,11 @@ for table in tables:
# https://github.com/go-gitea/gitea/blob/adf3f004b65135e9375ae60dfd0d9ecba340342e/models/migrations/v71.go#L43
# https://github.com/go-gitea/gitea/pull/4331
# TODO
if this_table == 'two_factor' and 'scratch_token' in row:
ScratchSalt = GetRandomString(10)
raw_ScratchHash = hashlib.pbkdf2_hmac('sha256', row['scratch_token'].encode(), ScratchSalt.encode(), 100000)
ScratchHash = binascii.hexlify(raw_ScratchHash).decode('utf-8')
row.pop('scratch_token')
row['scratch_salt'] = ScratchSalt
row['scratch_hash'] = ScratchHash
output = MARIADB.insert(this_table, row)