-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement Two-Factor Authentication #112
Conversation
Addresses the following: - Adds settings for development - Adds settings for production Contributes towards: #107
Addresses the following: - Adds model for email method of 2FA - Includes the migration history during development - Tweaks `Profile` model - Removes redundant model methods - Replaces custom full_name method with in-built Django one - Replaces `super()` call on `save` method with Python 3 syntax Contributes towards: #107
Addresses the following: - Adds the `EmailToken` model to the admin panel - Ensures the challenge token is not visible in the admin panel - Ensures the `EmailToken` panel is completely read-only - Removes unused models from the panel - Adjusts the image resizing function with a `SCALE_FACTOR` constant Contributes towards: #107
Addresses the following: - Override `LoginView` to account for the scenarios of device or email authentication as the second factor - `LoginView` now ensures that the user is taken through the 2FA process if they have not already done so - Email is sent upon generation of a code - Email is sent upon setup of an email code with user-friendly information on how long the code will last - Existing forms have been updated to make them clearer and some suplerflous methods have been removed from clean methods - Refactor some existing code to make clearer - Where beneficial, type hints and docstrings added Contributes towards: #107
Addresses the following: - Adds function to enable the calculcation of the challenge expiration date/time - Adds function to enable the calculcation of the token expiration date/time - Adds docstrings Contributes towards: #107
Addresses the following: - Adds mixin to enable a view to be conditionally available to users that have a device 2FA setup - Adds mixin to enable a view to be conditionally available to users that have an email 2FA setup - Adds mixin to enable a view to be conditionally available to users that have either a device or an email 2FA setup Contributes towards: #107
Addresses the following: - In order to make code more understandable and representative of what is actually going on, the `related_name` attribute's value was changed from `user` to `profile` - Changes made in API reference - Changes made in `PublishedManager` to manage blog `Post` objects - Changes also made in template references Contributes towards: #107
Addresses the following: - Replaces usage of `user.username` on the `User` model with the in-built Django convenience method of `get_username()` - Replaces usage of the `get_full_name()` method on the `Profile` model with the in-built Django convenience method of `get_full_name()` - Replaces references to the old implementations to the new ones in templates, API serializers, testing fixtures, feeds, and views code Contributes towards: #107
Addresses the following: - Adds messages to `login.html` template - Makes miscellaneous styling adjustments for readability and to work within constraint of maximum column width enforced by GitHub - Adds user-friendly text to the interface - Adds placeholders for form input fields - Contributed towards uniformity of anchor tag elements Contributes towards: #107
Addresses the following: - Amend template to handle the issue of a token - Add template to handle the confirmation of token setup and expiration Contributes towards: #107
Addresses the following: - Adds `TwoFactorAuthMixin` to `ProfileView` - Adds type hints within the `ProfileUpdateView` Contributes towards: #107
Addresses the following: - Adds fixture to simulate device authenticated user - Adds fixture to simulate email authenticated user Contributes towards: #107
Addresses the following: - Adds config settings to faciliate testing with pytest Contributes towards: #107
Addresses the following: - Adds and adjusts tests for the `TestProfileView` to account for the expected outcome now being different due to the factor that there is the custom `TwoFactorAuthUserMixin` added - Adjusts test for the `__str__` method to be in line with best practices Contributes towards: #107
Addresses the following: - Modifies f-string as per AI Sourcery refactoring suggestion Contributes towards: #107
Add Two-Factor Authentication by Email
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 1.31%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
ProfileView
has been implemented with the new mixin as a starting point. There are a few more views that need the mixin adding and the appropriate tests writing (see issue Two-Factor Authentication #107 for details)Loginview
has been customised to enforce that a method of two-factor authentication has been used.