1
1
from flask import Flask , Blueprint , request , render_template , session , redirect , url_for , flash , jsonify , send_file
2
2
from ._logger import logger
3
3
from ._gemini import _Gemini
4
- from passlib . hash import argon2
4
+ import argon2
5
5
from datetime import datetime
6
6
import ipaddress
7
7
import re
13
13
import urllib .parse
14
14
import sys
15
15
16
+ ph = argon2 .PasswordHasher ()
17
+
16
18
class _Gemini_GUI (object ):
17
19
18
20
def __init__ (self , flask_app : Flask ) -> None :
@@ -148,7 +150,7 @@ def gemini_install():
148
150
"g_serve_key" : g_serve_key
149
151
})
150
152
_Gemini .update_gemini_user ({
151
- "password" : argon2 .hash (password ),
153
+ "password" : ph .hash (password ),
152
154
})
153
155
logger .info (
154
156
"[+] Install gemini-self-protector successful.!" )
@@ -207,8 +209,11 @@ def gemini_login():
207
209
app_username = _Gemini .get_gemini_user ().username
208
210
app_password = _Gemini .get_gemini_user ().password
209
211
210
- password_check = argon2 .verify (password , app_password )
211
-
212
+ try :
213
+ password_check = ph .verify (app_password , password )
214
+ except argon2 .exceptions .VerifyMismatchError :
215
+ return render_template ('gemini-protector-gui/accounts/login.html' , msg = "Incorrect Username / Password" )
216
+
212
217
if username == app_username and password_check :
213
218
session ['gemini_logged_in' ] = True
214
219
flash ('Welcome back {}!' .format (
@@ -241,7 +246,7 @@ def gemini_profile():
241
246
return render_template ('gemini-protector-gui/home/profile.html' , msg = "Invalid password" )
242
247
243
248
_Gemini .update_gemini_config ({
244
- "gemini_app_password" : argon2 .hash (password ),
249
+ "gemini_app_password" : ph .hash (password ),
245
250
})
246
251
logger .info ("[+] Update password successful." )
247
252
return redirect (url_for ('nested_service.gemini_login' ))
@@ -271,6 +276,7 @@ def gemini_dashboard():
271
276
request_log = _Gemini .get_gemini_request_log ()
272
277
beharvior_log = _Gemini .get_gemini_behavior_log ()
273
278
# predict_server_status = _Gemini.health_check_predict_server()
279
+ server_performance = _Gemini .g_server_performance ()
274
280
275
281
sorted_request_log_data = sorted (
276
282
request_log , key = lambda x : x .time )
@@ -281,7 +287,7 @@ def gemini_dashboard():
281
287
start_index = (page - 1 ) * per_page
282
288
end_index = start_index + per_page
283
289
limited_request_log_data = sorted_request_log_data [start_index :end_index ]
284
-
290
+
285
291
attack_counts = {
286
292
'Malicious Request' : 0 ,
287
293
'ACL Block' : 0 ,
@@ -320,7 +326,8 @@ def gemini_dashboard():
320
326
_gemini_notification_channel = gemini_config .notification_channel ,
321
327
_gemini_attack_counts = attack_counts ,
322
328
_any_attack_count_gt_zero = any_attack_count_gt_zero ,
323
- _gemini_beharvior_log_data = beharvior_log
329
+ _gemini_beharvior_log_data = beharvior_log ,
330
+ _server_performance = server_performance
324
331
)
325
332
except Exception as e :
326
333
logger .error ("[x_x] Something went wrong at {0}, please check your error message.\n Message - {1}" .format (
0 commit comments