-
Notifications
You must be signed in to change notification settings - Fork 24
[WJ-1002] Add password and TOTP support #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I opened TimDumol/rust-otp#4 to request that it be published to crates.io so we can reference it normally.
Also adds the MfaSecrets helper structure which securely generates random data for use in the TOTP scheme.
2ded854
to
468539d
Compare
Also has verify_internal(), and the delay in between failed requests (0.1 seconds, or 100 milliseconds).
Not sure how this was missing it or it wasn't causing issues.
Codecov Report
@@ Coverage Diff @@
## develop #1048 +/- ##
===========================================
- Coverage 48.84% 2.24% -46.61%
===========================================
Files 296 96 -200
Lines 8985 3704 -5281
===========================================
- Hits 4389 83 -4306
+ Misses 4596 3621 -975
|
Haven't gotten a response from TimDumol/rust-otp#4. If enough time passes without interaction from the maintainer, I'm wondering if we should fork it and maintain it ourselves. |
Yossipossi1
approved these changes
Oct 27, 2022
thanks @Yossipossi1 |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the cryptographic basics for password verification (hashing via argon2), multi-factor authentication (MFA) using temporary one-time passwords (TOTP), and basic methods for setting each of those values. We will eventually need to encode the MFA secret in a QR code but that's out of scope at the moment.
The addition of cryptographic operations here provides a foundation for later authentication and related changes that will come as the account system develops.
The new services added are:
PasswordService
-- wraps theargon2
crate by providing password hashing methodsMfaService
-- validates TOTP and recovery codes to supplement password auth, if enabledAuthenticationService
-- calls the above services to perform high-level authentication operationsI have tried to be careful with my implementations, ensuring that I source random values from a CSPRNG, that any comparison operations are constant-time to avoid timing attacks, that failed authentications result in a constant time sleep to avoid brute-forcing, and that passwords are appropriately hashed before being stored in the database. (Relevant note there, the TOTP secret cannot be encrypted, as its exact value is needed on the server end. I did some research on this before and it seems the typical approach is to just store it as-is, like the password's salt.)