Skip to content

Why is TOTP code not getting burnt after successful usage? #214

@mmfnaja

Description

@mmfnaja

I use the email MFA method to get an OTP code. Now if I logout and login quickly I am getting the same code.

According to https://datatracker.ietf.org/doc/html/rfc6238#section-5.2, "The verifier MUST NOT accept the second attempt of the OTP after the successful validation has been issued for the first OTP, which ensures one-time only use of an OTP."

However I found in the def dispatch_message(self) implementation of class SendMailMessageDispatcher(AbstractMessageDispatcher), the following code:

context = {"code": self.create_code()}

The create_code function of AbstractMessageDispatcher returns the following:

self._get_otp().now()

where the _get_otp() returns a TOTP object.

Additionally, the authenticate_second_step_command just verify the code via self._get_otp().verify(otp=code) and fails to burn an already used code after successful verification.

So, I think the reason I am getting the same code is OK, but does this mean the library didn't follow the RFC consideration? Or do you want the developers who uses the package to implement our own burning mechanism? Please could you mind sharing some guidelines?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions