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

Views that require new OTP authentication for every POST action #577

Open
PetrDlouhy opened this issue Dec 22, 2022 · 0 comments
Open

Views that require new OTP authentication for every POST action #577

PetrDlouhy opened this issue Dec 22, 2022 · 0 comments

Comments

@PetrDlouhy
Copy link
Contributor

PetrDlouhy commented Dec 22, 2022

I would like to increase security of some views such as submitting payouts, handling money or other potentially risky tasks.
To increase the security I would like to let the user re-submit his/hers OTP once again for every POST action.

Expected Behavior

The scenario when this might help is such that the user leaves his/hers computer with session already authenticated and goes off. The some other person can come in and for example steal all money from his/hers account.

Current Behavior

In current logic of django-two-factor-auth it is also possible to disable 2FA without any additional authentication and set a new one.
It would be needed to require secondary 2FA also for /account/two_factor/disable/ view in order to make this protection effective.

Possible Solution

The described scenario could be prevented if the user re-submits OTP code before/during the making POST request to the security demanding view.

The second possibility how to implement this might be to modify the @otp_required/OTPRequiredMixin decorator/mixin with requirement for maximal age of the authentication. So for example I could decorate the risky view with:

from django_otp.decorators import otp_required

@otp_required(max_age=5)  # 5 seconds
def my_view(request):
    pass
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

No branches or pull requests

1 participant