Skip to content
Commits on Source (4)
...@@ -6,7 +6,7 @@ from flask import jsonify, session, redirect, url_for ...@@ -6,7 +6,7 @@ from flask import jsonify, session, redirect, url_for
import config import config
from version import __version__, __branch__, __commit__, __commiturl__, __treeurl__ import version
import utils import utils
...@@ -20,7 +20,7 @@ def ping(): ...@@ -20,7 +20,7 @@ def ping():
return "pong" return "pong"
@adm_view.route( "/version" ) @adm_view.route( "/version" )
def version(): def route_version():
""" """
Function to report the version of the web app. The version.py file is Function to report the version of the web app. The version.py file is
re-generated by the CI/CD for production. re-generated by the CI/CD for production.
...@@ -28,11 +28,11 @@ def version(): ...@@ -28,11 +28,11 @@ def version():
try: try:
return jsonify( { return jsonify( {
"error": False, "error": False,
"version": __version__, "version": version.__version__,
"branch": __branch__, "branch": version.__branch__,
"commit": __commit__, "commit": version.__commit__,
"commiturl": __commiturl__, "commiturl": version.__commiturl__,
"treeurl": __treeurl__ "treeurl": version.__treeurl__
} ) } )
except: except:
......
...@@ -204,8 +204,9 @@ def do_login(): ...@@ -204,8 +204,9 @@ def do_login():
# Check for outdated password and update it in the database if needed # Check for outdated password and update it in the database if needed
_, _, salt, iterations, _ = user[ "password" ].split( "$" ) _, _, salt, iterations, _ = user[ "password" ].split( "$" )
iterations = int( iterations )
if iterations != config.PASSWORD_NB_ITERATIONS or salt.len() != config.PASSWORD_SALT_LENGTH: if iterations != config.PASSWORD_NB_ITERATIONS or len( salt ) != config.PASSWORD_SALT_LENGTH:
new_password = utils.hash.pbkdf2( new_password = utils.hash.pbkdf2(
form_password, form_password,
utils.rand.random_data( config.PASSWORD_SALT_LENGTH ), utils.rand.random_data( config.PASSWORD_SALT_LENGTH ),
...@@ -748,7 +749,7 @@ def do_password_reset_thread( email, localapp ): ...@@ -748,7 +749,7 @@ def do_password_reset_thread( email, localapp ):
return False return False
else: else:
users = config.db.query_fetchall( "SELECT id, username, email FROM users" ) users = config.db.query_fetchall( "SELECT id, username, email FROM users ORDER BY username ASC" )
found = [] found = []
...@@ -759,6 +760,22 @@ def do_password_reset_thread( email, localapp ): ...@@ -759,6 +760,22 @@ def do_password_reset_thread( email, localapp ):
continue continue
elif utils.hash.pbkdf2( email ).verify( user[ "email" ] ): elif utils.hash.pbkdf2( email ).verify( user[ "email" ] ):
# Check outdated email hash
_, _, salt, iterations, _ = user[ "email" ].split( "$" )
iterations = int( iterations )
if iterations != config.EMAIL_NB_ITERATIONS or len( salt ) != config.EMAIL_SALT_LENGTH:
new_email_hash = utils.hash.pbkdf2(
email,
utils.rand.random_data( config.EMAIL_SALT_LENGTH ),
config.EMAIL_NB_ITERATIONS
).hash()
config.db.query( "UPDATE users SET email = %s WHERE id = %s", ( new_email_hash, user[ "id" ] ) )
config.db.commit()
####################################################################
user_id = hashlib.sha512( utils.rand.random_data( 100 ) ).hexdigest() user_id = hashlib.sha512( utils.rand.random_data( 100 ) ).hexdigest()
#################################################################### ####################################################################
......
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
/* Get the version of ICNML */ /* Get the version of ICNML */
$.ajax( { $.ajax( {
url: "{{ url_for( 'adm.version' ) }}", url: "{{ url_for( 'adm.route_version' ) }}",
dataType: "json", dataType: "json",
method: "GET", method: "GET",
success: function( data ){ success: function( data ){
......