[keycloak-user] Custom message in authenticator script

Vagelis Savvas vagelis.savvas at gmail.com
Tue Dec 11 10:45:59 EST 2018


Hello,
I have created a theme and extended the base login form with an extra 
input field.
I've also created a Script Authenticator that checks the value of the 
extra field and permits or not the authentication.
My authenticator script runs after the builtin 'Username Password form' 
(Browser flow).
Now I would like to do two things when authentication fails because of 
my script:

1. Use a custom i18n error message instead of showing one of  the 
messages of the builtin AuthenticationFlowError. Is there a way to do so?
2. Stay on the login page and show the error message instead of being 
sent to a 'We're sorry...' page with a link back to the login form.
For instance the builtin 'Username Password form' stays on the login 
form with an error message when authentication fails which is nice and 
clean.
Currently I fail the authentication with 'context.clearUser(); 
context.failure(AuthenticationFlowError.INVALID_CREDENTIALS);'
but I've tried various methods from 'context' without achieving either 1 
or 2 of my requirements.

Cheers,
Vagelis



More information about the keycloak-user mailing list