Hi! How can i override a keycloak class (i.g: IdentityProviderAuthenticator)?
I have already built the package and created the respective file in META-INF/services but when i execute keycloak, it keeps the original IdentityProviderAuthenticator class. It is possible to override any class of keycloak using this method?
I believe there is no way to remove the default authenticators with an SPI. You would have to generate a custom keycloak build for that.
But you could probably just create your own authenticator, based on a default one and introduce it in the flow you’re interested in.
2 Likes
Thank you! i did something like you have said
If anyone is interested or there are a better approach:
My problem:
When i login via social authentication, there is no “Remember me” option, and KC creates the “KEYCLOAK_IDENTITY_LEGACY” cookie which expires when the browser closes, and then everytime i close and open the browser i need to login.
Possible solution (it works for me, but maybe there will be a better approach):
I override the Identity providers i use (i.g: Google) and in GoogleIdentityProvider.java just made a function that overrides the “authenticationFinished” method:
@Override
public void authenticationFinished(AuthenticationSessionModel authSession, BrokeredIdentityContext context) {
super.authenticationFinished(authSession, context);
authSession.setAuthNote(Details.REMEMBER_ME, "true");
}
It will add an auth note “Remember me” in true (this auth note is created on UserPasswordForm when the “remember me” checkbox is checked) and voilà ! It creates the “KEYCLOAK_IDENTITY_LEGACY” with expiration
(which fix the problem for me)