# Username, Password, AND optional OTP on the login page

**URL:** <https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124>\
**Category:** Getting advice\
**Tags:** themes\
**Created:** [June 21, 2025, 6:04pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124 "2025-06-21T18:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanthor](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/hanthor/32/12204_2.png) [@hanthor](https://forum.keycloak.org/u/hanthor)\
**Post date:** [June 21, 2025, 6:04pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/1 "2025-06-21T18:04:30Z")

</div>

I am wondering if it is possible to implement a login page with the OTP field on the front page. Like how Fedora has theirs:

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/a/ac2160037e60639ee9716229fb1cd12b0b8e3b31.png)

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 22, 2025, 3:59pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/2 "2025-06-22T15:59:42Z")

</div>

You could implement a custom Authenticator to do a similar thing.

We’ve got an Email OTP Authenticator that sends an OTP to the user’s email after the user is identified (either with username or username and password). That might help you get started.

> **[GitHub - p2-inc/keycloak-magic-link: Magic Link Authentication for Keycloak](https://github.com/p2-inc/keycloak-magic-link?tab=readme-ov-file#email-otp)**
>
> Magic Link Authentication for Keycloak

Can you help me understand _how_ the user got the OTP without identifying themselves? I’m not familiar with the Fedora login flow.

---

<div class="post-metadata">

**Author:** ![hanthor](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/hanthor/32/12204_2.png) [@hanthor](https://forum.keycloak.org/u/hanthor)\
**Post date:** [June 22, 2025, 4:30pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/3 "2025-06-22T16:30:32Z")

</div>

Yes it would really be a TOTP. it would be in a authenticator app and password manager. Password managers could fill in all three at once and you can click login

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 22, 2025, 5:46pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/4 "2025-06-22T17:46:13Z")

</div>

Then you should look at the Authenticators for username/password and otp. You can probably combine those into one custom that will allow you to do both at the same time.

> <https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/authentication/authenticators/browser/UsernamePasswordForm.java>

> <https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/authentication/authenticators/browser/OTPFormAuthenticator.java>

---

<div class="post-metadata">

**Author:** ![embesozzi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/embesozzi/32/12390_2.png) [@embesozzi](https://forum.keycloak.org/u/embesozzi)\
**Post date:** [June 22, 2025, 8:03pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/5 "2025-06-22T20:03:56Z")

</div>

As xgp was saying, customization makes it possible.

Nevertheless, the recommendation is to follow the Identify-First approach. This means the first step is user identification, followed by the appropriate authentication step. It no longer makes sense to do everything at once in the first step.

---

<div class="post-metadata">

**Author:** ![hanthor](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/hanthor/32/12204_2.png) [@hanthor](https://forum.keycloak.org/u/hanthor)\
**Post date:** [June 23, 2025, 4:15pm UTC](https://forum.keycloak.org/t/username-password-and-optional-otp-on-the-login-page/30124/6 "2025-06-23T16:15:54Z")

</div>

Turned out they are using LDAP for TOTP and just need the oto concatenated to the password. Here’s what I made for anyone else looking: [GitHub - hanthor/almalinux-keycloak-theme](https://github.com/hanthor/almalinux-keycloak-theme)
