I want to implement single password authorization instead of Basic-Auth in Mojolicious.
I need the standard basic-auth field to be displayed, but to only ask the user for a password, without having to see the username field.
plugin 'basic_auth', { realm => '', authenticator => sub {
my ($password) = @_;
return $password eq 'correct_password';
}};
my $authenticated = $c->basic_auth(realm => 'Restricted area', username => '', password => 'password');
unless ($authenticated) {
return { error => 'Authentication failed' };
}
Basic authentication is very easy to implement, but I did not find the ability to request only a password.
Maybe someone knows how to request only an access password?
I tried basic auth, but there is no possibility to exclude login field.

Why not just use HTML's
<dialog>element? Widely adopted since 2022. Easy to make with only a greeting, password field, and Log In and Cancel buttons. With an inner form it can send the password to your Mojo - or any other - script the usual way. And you can style the dialog as needed. If you want a minimal example, I'll post one. Ref: MDN Docs