Skip to content
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

make hotp invalid after password reset #1054

Merged
merged 3 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
- Catch KeyNotFoundError when user tries to give access to a project they themselves do not have access to ([#1045](https://github.com/ScilifelabDataCentre/dds_web/pull/1045))
- Display an error message when the user makes too many authentication requests. ([#1034](https://github.com/ScilifelabDataCentre/dds_web/pull/1034))
- New endpoint for Unit Personnel and Admins to list the other Unit Personnel / Admins within their project ([#1050](https://github.com/ScilifelabDataCentre/dds_web/pull/1050))
- Make previous HOTP invalid at password reset ()
i-oden marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions dds_web/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ def generate_HOTP_token(self):
hotp = twofactor_hotp.HOTP(self.hotp_secret, 8, hashes.SHA512())
return hotp.generate(self.hotp_counter)

def reset_current_HOTP(self):
"""Make the previous HOTP as invalid by nulling issue time and increasing counter."""
self.hotp_issue_time = None
self.hotp_counter += 1

def verify_HOTP(self, token):
"""Verify the HOTP token.

Expand Down
3 changes: 3 additions & 0 deletions dds_web/web/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ def reset_password(token):

# Validate form
if form.validate_on_submit():
# Clear out hotp
user.reset_current_HOTP()

# Delete project user keys for user
for project_user_key in user.project_user_keys:
db.session.delete(project_user_key)
Expand Down