Storing Passwords
When storing passwords, we cannot store these passwords in a raw string format. If we did and there was a data leak, all of the passwords would be compromised. To reduce the risk of passwords being compromised, we hash the passwords before storing them in the database. We also must create our unique IDs when creating users to be inserted into the database.
To enable us to write the code that stores passwords new users, we must add the following dependencies:
# nanoservices/auth/dal/Cargo.toml
argon2 = { version = "0.5.3", features = ["password-hash"]}
uuid = {version = "1.8.0", features = ["serde", "v4"]}
rand = "0.8.5"
The uses of the crates are described below:
Argon2
: used for the password hashing and verification.
uuid
: for the creation of unique IDs.
rand
: random generation functionality used for creating a "salt string" for hashing the password.
With these dependencies, we now need to use the...