Skip to content

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

Open
edulix wants to merge 4 commits into
mainfrom
feat/meta-12616/main
Open

feat(message-otp): opt-in auto-create of message-otp credential at login#2896
edulix wants to merge 4 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

github-actions Bot commented Jul 29, 2026

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-30 07:33 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

edulix added 2 commits July 30, 2026 07:22
# Conflicts:
#	packages/keycloak-extensions/message-otp-authenticator/pom.xml
The Auto-create OTP credential option is channel agnostic: it creates the
same message-otp credential for a voter that has an email address or a
mobile number, and the Message Courier setting decides how the code is
delivered. The tutorial read as email only.

Rename it to "Email and SMS OTP for Imported Voters", document the SMS
courier and the telephone user attribute it reads, note that a single
credential covers both channels, and add the dummy SMS sender log command
used in the development environment. Screenshots are unchanged and still
show an email-only voter, which the text now calls out.
@edulix
edulix marked this pull request as ready for review July 30, 2026 07:32
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