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

Add scratch code support for 2FA; fixes #784 #1334

Merged
merged 1 commit into from
Jun 16, 2020

Conversation

Carson-Tang
Copy link
Member

image
image
image
image

@Carson-Tang Carson-Tang force-pushed the scratch-code branch 10 times, most recently from 985948a to ac33f05 Compare April 24, 2020 00:55
@Carson-Tang Carson-Tang force-pushed the scratch-code branch 7 times, most recently from d17bd47 to c2cad17 Compare May 4, 2020 04:50
@Carson-Tang
Copy link
Member Author

Fixed font
image

@Carson-Tang Carson-Tang force-pushed the scratch-code branch 2 times, most recently from 89b832f to b775fa1 Compare May 10, 2020 01:23
@Carson-Tang
Copy link
Member Author

Carson-Tang commented May 10, 2020

Screenshots of latest commit:
image
image

image
image

@Carson-Tang Carson-Tang force-pushed the scratch-code branch 2 times, most recently from 750a291 to b68ccac Compare May 10, 2020 02:23
judge/forms.py Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
judge/models/profile.py Outdated Show resolved Hide resolved
judge/models/profile.py Outdated Show resolved Hide resolved
@Carson-Tang Carson-Tang force-pushed the scratch-code branch 3 times, most recently from a1e6a30 to 289c987 Compare June 7, 2020 05:37
Copy link
Contributor

@fluix-dev fluix-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the hard work 😄

elif self.profile.is_totp_enabled and totp_or_scratch_code:
if pyotp.TOTP(self.profile.totp_key).verify(totp_or_scratch_code, valid_window=self.TOLERANCE):
return
elif totp_or_scratch_code in json.loads(self.profile.scratch_codes):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually this should probably be added into totp_or_scratch_code_validators, converting its contests to a class, but that's for another PR.

Copy link
Contributor

@fluix-dev fluix-dev Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (suggestion) is also just over complicating things.

@Carson-Tang Carson-Tang requested review from Xyene and Ninjaclasher June 8, 2020 03:36
Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from these remaining small fixes, this PR looks good to me 👍

dmoj/urls.py Outdated Show resolved Hide resolved
templates/registration/two_factor_auth.html Outdated Show resolved Hide resolved
templates/user/edit-profile.html Outdated Show resolved Hide resolved
templates/user/edit-profile.html Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
@Carson-Tang
Copy link
Member Author

Suggested changes resolved.

judge/forms.py Outdated Show resolved Hide resolved
judge/models/profile.py Outdated Show resolved Hide resolved
@Carson-Tang Carson-Tang force-pushed the scratch-code branch 6 times, most recently from b68c525 to 8652bd1 Compare June 13, 2020 03:05
Copy link
Member

@quantum5 quantum5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good.

templates/common-content.html Outdated Show resolved Hide resolved
templates/common-content.html Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
judge/forms.py Outdated Show resolved Hide resolved
Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Xyene Xyene merged commit ead2202 into DMOJ:master Jun 16, 2020
@Carson-Tang Carson-Tang deleted the scratch-code branch June 24, 2020 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants