Skip to content

Conversation

@johanib
Copy link
Contributor

@johanib johanib commented Jan 13, 2026

Prior to this change, there was no way to determine if a two-factor provider needed preparation before authentication.

This change introduces the needsPreparation method in the TwoFactorProviderInterface and its implementations, allowing the system to skip the preparation process for providers that do not require it. The preparation process requires state.

For example:
Prior to this change, if no state was available, the Totp and Google authenticators would fail, even if they are stateless.

Now, non-bc breaking.

Fixes #306

Prior to this change, there was no way to determine if a two-factor provider needed preparation before authentication.

This change introduces the needsPreparation method in the TwoFactorProviderInterface and its implementations, allowing the system to skip the preparation process for providers that do not require it. The preparation process requires state.

For example:
Prior to this change, if no state was available, the  Totp and Google authenticators would fail, even if they are stateless.

Co-authored-by: Tjeerd <tjeerd@ibuildings.nl>
@johanib johanib force-pushed the optional-preparation-4-non-breaking branch from d7a1bf2 to 2df4f9c Compare January 13, 2026 07:45
@johanib johanib marked this pull request as ready for review January 13, 2026 07:46
Prior to this change, the needsPreparation method would break existing
implementations.

This change makes the change not break existing TwoFactorProviders by not actually defining the `needsPreparation` in the interface.
This is to be implemented in version 9 of the 2fa package.
@johanib johanib force-pushed the optional-preparation-4-non-breaking branch from 2df4f9c to 81f6039 Compare January 13, 2026 07:49
Copy link
Owner

@scheb scheb 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 going through the effort adjusting the implementation. I believe we can improve the test case a bit. Other than that, I'm happy to merge that in.

@johanib johanib force-pushed the optional-preparation-4-non-breaking branch 2 times, most recently from 7484f6b to 0ab4058 Compare January 21, 2026 13:58
…the TwoFactorProvider does not have the needsPreparation function.

Also adds `needsPreparation` to TwoFactorProviderInterface.
@johanib johanib force-pushed the optional-preparation-4-non-breaking branch from 0ab4058 to 3d141c4 Compare January 21, 2026 14:08
@scheb scheb merged commit fa7a002 into scheb:8.x Jan 24, 2026
11 checks passed
@scheb
Copy link
Owner

scheb commented Jan 24, 2026

Released as v8.3.0

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.

Add support for 2FA in applications without state

2 participants