-
Notifications
You must be signed in to change notification settings - Fork 93
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
Added throttling to token generation (Closes #48) #122
Merged
psagers
merged 14 commits into
django-otp:master
from
demestav:feature/48-add-token-generation-throttling
Nov 8, 2023
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8aa2230
Added throttling to token generation (Closes #48)
demestav 4f20255
Refactored code to suit better the current structure of codebase
demestav 72291ef
Added get_generation_interval method to GenerationThrottlingMixin
demestav b673da6
Fixed import sort
demestav b966e1d
Fixed check and generation of token
demestav bb10746
Removed generate token, adapted EmailDevice, added tests
demestav dbc3fb5
Fixed remaining time message, and added a test
demestav 29ebe3e
Decoupled generic cooldown tests with email specific cooldown tests
demestav dbe61d7
Moved email token delivery process to a private method, for clarity
demestav 5b49259
Consistent naming of new feature as Cooldown
demestav 131a10e
Rename cooldown setting for email plugin
demestav 87ba728
Added documentation
demestav 3746d8c
Commit timestamp update, and improved tests to validate that.
demestav f3ab24b
Updated documentation
demestav File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
18 changes: 18 additions & 0 deletions
18
src/django_otp/plugins/otp_email/migrations/0005_emaildevice_last_generated_timestamp.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.16 on 2023-05-12 11:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('otp_email', '0004_throttling'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='emaildevice', | ||
name='last_generated_timestamp', | ||
field=models.DateTimeField(blank=True, help_text='The last time a token was generated for this device.', null=True), | ||
), | ||
] |
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This never gets saved. As importantly, the tests aren't catching this (see companion note in the tests).
(Hint: try swapping these two lines. Adding the technically redundant
commit=True
will help to highlight the fact that you're relying ongenerate_token
to save the model instance for you.)