Describe the issue
I hit two MFA-related issues while testing local auth with caddy-security:
Dockerfile ->
FROM caddy:2-builder AS caddy_builder
RUN xcaddy build --with github.com/greenpau/caddy-security
FROM caddy:2
COPY --from=caddy_builder /usr/bin/caddy /usr/bin/caddy
-
Frontend bug on MFA enrollment page
On the MFA enrollment page, clicking the Add button does nothing.
No network request is sent.
In the browser console, I see this error:
An invalid form control with name='label' is not focusable
It looks like the form contains a required label field that is hidden or otherwise not focusable, so HTML form validation blocks submission before any request is sent.
As a workaround, manually setting a value for the hidden label input in DevTools makes the form submit successfully, for example:
document.querySelector('input[name="label"]').value = 'Auth'
-
MFA prompt appears twice
After MFA is configured, I am prompted for OTP twice during login when require mfa is enabled.
From the logs, I can see these checkpoints:
Authenticate with password
Multi-factor authentication app
Multi-factor authentication
This results in what feels like a double MFA flow.
When I remove require mfa, the flow becomes normal again and I only get a single OTP prompt.
So there seem to be two separate problems:
- a frontend/UI bug on the MFA enrollment page (
label field)
- a duplicated MFA challenge flow when
require mfa is enabled alongside TOTP app authentication
Configuration
Paste full Caddyfile below:
{
order authenticate before respond
order authorize before basicauth
security {
local identity store localdb {
realm local
path /etc/caddy/users.json
}
authentication portal mainportal {
crypto default token lifetime 3600
crypto key sign-verify {env.JWT_SHARED_KEY}
enable identity store localdb
cookie domain alperensozer.com
cookie path /
cookie lifetime 43200
cookie insecure off
trust login redirect uri domain suffix alperensozer.com path prefix /
trust logout redirect uri domain suffix alperensozer.com path prefix /
transform user {
match origin local
action add role authp/user
require mfa
}
}
authorization policy mainpolicy {
set auth url https://auth.alperensozer.com
allow roles authp/admin authp/user
crypto key verify {env.JWT_SHARED_KEY}
}
}
}
auth.alperensozer.com {
route {
authenticate with mainportal
}
}
proxy.alperensozer.com {
route {
authorize with mainpolicy
reverse_proxy wgclient:5800
}
}
Version Information
Provide output of caddy list-modules --versions | grep -E "(auth|security)" below:
Expected behavior
- On the MFA enrollment page, clicking Add should submit normally without requiring a hidden
label field workaround in the browser console.
- When TOTP app MFA is configured, login should require only one OTP challenge.
- Enabling
require mfa should not introduce what appears to be an additional MFA checkpoint on top of the TOTP app challenge.
Additional context
-
I am using local identity store (users.json).
-
MFA enrollment succeeds only after manually populating the hidden label input via DevTools.
-
Browser console error during failed enrollment:
An invalid form control with name='label' is not focusable
-
Logs during login with require mfa enabled show multiple checkpoints, including both:
Multi-factor authentication app
Multi-factor authentication
This is what makes the login flow ask for OTP twice.
If helpful, I can also provide:
- browser screenshots of the MFA enrollment page
- console output
- relevant auth/security logs
Describe the issue
I hit two MFA-related issues while testing local auth with
caddy-security:Dockerfile ->
Frontend bug on MFA enrollment page
On the MFA enrollment page, clicking the Add button does nothing.
No network request is sent.
In the browser console, I see this error:
An invalid form control with name='label' is not focusableIt looks like the form contains a required
labelfield that is hidden or otherwise not focusable, so HTML form validation blocks submission before any request is sent.As a workaround, manually setting a value for the hidden
labelinput in DevTools makes the form submit successfully, for example:MFA prompt appears twice
After MFA is configured, I am prompted for OTP twice during login when
require mfais enabled.From the logs, I can see these checkpoints:
Authenticate with passwordMulti-factor authentication appMulti-factor authenticationThis results in what feels like a double MFA flow.
When I remove
require mfa, the flow becomes normal again and I only get a single OTP prompt.So there seem to be two separate problems:
labelfield)require mfais enabled alongside TOTP app authenticationConfiguration
Paste full
Caddyfilebelow:Version Information
Provide output of
caddy list-modules --versions | grep -E "(auth|security)"below:Expected behavior
labelfield workaround in the browser console.require mfashould not introduce what appears to be an additional MFA checkpoint on top of the TOTP app challenge.Additional context
I am using local identity store (
users.json).MFA enrollment succeeds only after manually populating the hidden
labelinput via DevTools.Browser console error during failed enrollment:
An invalid form control with name='label' is not focusableLogs during login with
require mfaenabled show multiple checkpoints, including both:Multi-factor authentication appMulti-factor authenticationThis is what makes the login flow ask for OTP twice.
If helpful, I can also provide: