Skip to content

Commit

Permalink
Merge pull request #1054 from ScilifelabDataCentre/reset-hotp
Browse files Browse the repository at this point in the history
make hotp invalid after password reset
  • Loading branch information
i-oden authored Mar 14, 2022
2 parents ccca27f + bd44287 commit 29e4a6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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 ([#1054](https://github.com/ScilifelabDataCentre/dds_web/pull/1054))
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

0 comments on commit 29e4a6f

Please sign in to comment.