So far I used SHA256 to hash passwords (I know, terrible) and now I would like to switch to Argon2.
My problem is that if I understand it correctly I am going to have to store the plain text password in a session variable now.
Now I am storing the SHA256 hash in session variables, and I have a check_user
function that check if the user is still logged in for most of my functions.
def check_user(request):
if 'email' not in request.session or not request.session['email']:
return False
if 'pw_hash' not in request.session or not request.session['pw_hash']:
return False
try:
Clients.objects.get(pk=request.session['email'])
except Clients.DoesNotExist:
return False
if request.session['pw_hash'] != Clients.objects.get(pk=request.session['email']).password:
return False
return True
If I switch to Argon2, as far as I understand I ll have to store the plain password in the session variable to be able to use PasswordHasher().verify
, which is IMO a bad practice.
What is the recommended way for this problem?