Skip to content

Commit

Permalink
fixed password check during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
bkellenb committed Nov 19, 2021
1 parent 58da5b7 commit 97ee9fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion constants/version.py
Expand Up @@ -10,7 +10,7 @@
2020-21 Benjamin Kellenberger
'''

AIDE_VERSION = '2.1.211118'
AIDE_VERSION = '2.1.211119'


MIN_FILESERVER_VERSION = '2.0.210225' # minimum required version for FileServer, due to recent changes
Expand Down
7 changes: 3 additions & 4 deletions setup/setupDB.py
Expand Up @@ -14,9 +14,10 @@
os.environ['AIDE_MODULES'] = 'FileServer' # for compatibility with Celery worker import

import argparse
import bcrypt
from constants.version import AIDE_VERSION
from util.configDef import Config
from modules import Database, UserHandling
from modules import Database
from setup.migrate_aide import migrate_aide


Expand All @@ -38,8 +39,6 @@ def add_update_superuser(config, dbConn):
adminPass = config.getProperty('Project', 'adminPassword')
if adminPass is None or not len(adminPass):
raise Exception('No password defined for admin account in configuration file.')
uHandler = UserHandling.backend.middleware.UserMiddleware(config, dbConn)
adminPass = uHandler._create_hash(adminPass.encode('utf8'))

# get current values
currentMeta = dbConn.execute('''
Expand All @@ -56,7 +55,7 @@ def add_update_superuser(config, dbConn):
currentMeta = currentMeta[0]
if currentMeta['email'] != adminEmail:
changes['adminEmail'] = True
if bytes(currentMeta['hash']) != adminPass:
if not bcrypt.checkpw(adminPass.encode('utf8'), bytes(currentMeta['hash'])):
changes['adminPassword'] = True

if isNewAccount or len(changes):
Expand Down

0 comments on commit 97ee9fc

Please sign in to comment.