Skip to content

feat(message-otp): opt-in auto-create of message-otp credential at login - #2896

Draft
edulix wants to merge 2 commits into
mainfrom
feat/meta-12616/main
Draft

feat(message-otp): opt-in auto-create of message-otp credential at login#2896
edulix wants to merge 2 commits into
mainfrom
feat/meta-12616/main

Conversation

@edulix

@edulix edulix commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Fixes sequentech/meta#12616

What

Adds an opt-in setting to the message-otp-authenticator Keycloak extension to auto-create the message-otp credential during login for non-deferred users.

Why

Voters imported or edited through the admin interface get their phone/email attributes set but never receive a stored message-otp credential. In flows where the message OTP authenticator is an ALTERNATIVE execution (e.g. combined with passkeys), configuredFor() returned false for these users, silently filtering the OTP option out of the credential selection list and failing the flow with a generic invalid_user_credentials error.

How

  • New AUTO_CREATE_CREDENTIAL_ATTRIBUTE config key in Utils.
  • New boolean ProviderConfigProperty "Auto-create OTP credential" in MessageOTPAuthenticatorFactory, disabled by default.
  • MessageOTPAuthenticator.configuredFor() reworked: for non-deferred users without the stored credential, if the property is enabled and the user has a mobile number or email configured, it creates MessageOTPCredentialModel(isSetup=true) on the fly and reports configured — no enrollment required action and no voter import/edit changes needed.
  • Deferred-user mode keeps relying on auth notes and never requires nor creates a stored credential.
  • Existing behavior is unchanged while the property remains disabled.

Testing

New MessageOTPAuthenticatorTest with 10 unit tests covering: default-off no-op, credential creation with mobile / email-only, no address, existing credential not duplicated, null user, deferred mode with the new property both enabled and disabled, and the factory property default value.

Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

edulix added 2 commits July 22, 2026 19:10
Add a new boolean authenticator config property "Auto-create OTP
credential" (autoCreateCredentialAttribute, disabled by default). When
enabled, configuredFor() auto-creates the message-otp credential for
non-deferred users that have a mobile number or email configured, so
imported/edited voters can use the OTP alternative without an
enrollment required action and without changing voter import/edit.

Deferred-user mode keeps relying on auth notes and never requires nor
creates a stored credential, fixing the silent filtering of the OTP
alternative that ended in a generic invalid_user_credentials error.

Includes unit tests (MessageOTPAuthenticatorTest, 10 tests) and junit
jupiter + mockito test dependencies for the module.

Related: sequentech/meta#12616
Document the opt-in Auto-create OTP credential option: why imported
voters were silently skipping the OTP sub-flow, how to wire the
conditional OTP sub-flow into the browser flow, how to enable the
option, what the voter sees, and how to confirm the message-otp
credential was created.

Screenshots were captured against a dev election event configured
end to end with an email-only voter.

Related: sequentech/meta#12616
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://docs.sequentech.io/docusaurus/pr-preview/pr-2896/

Built to branch doc-previews at 2026-07-29 18:19 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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.

1 participant