rusthashrust-axumaxum-loginargon2

How to create argon2 password hashes with axum_login?


When I manually create user records in my database, with passwords such as:

$argon2id$v=19$m=19456,t=2,p=1$h8H23N0TGnue7RFRVwaOH$AZkmgLWbRdU8shs3I20Y7q

the axum_login crate lets me authenticate successfully.

I've not been able to find out how to use axum_login to create these $argon2id... hashes. I need to be able to do this to add new users and allow existing users to change their passwords.

My thoughts are:

How do I turn plaintext passwords into argon2 hashes which will "just work" with axum_login?


Solution

  • Not exactly thing you're asking for, but I have found using the argon2 and password-hash crates directly in a /login endpoint, minting a JWT, putting that in request headers and requiring/extracting a valid one via a axum::extract::FromRequestParts in other endpoints that need auth to be less hassle than stateful session management.

    How do I turn plaintext passwords into argon2 hashes which will "just work" with axum_login?