Inject dynamic variable from backend java to freemarker template

I am using the “createCommonAttributes” of FreeMarkerLoginFormsProvider to add my custom attribute and inject in the login.ftl of keycloak. Below is the method. I am using “FreeMarkerLoginFormsProvider” and its factory “FreeMarkerLoginFormsProviderFactory”. I have declared my custom provider class that implememnts “FreeMarkerLoginFormsProviderFactory” in provider Meta-inf/services/org.keycloak.forms.login.LoginFormsProviderFactory, but its not working. I am using embedded spring boot keycloak. What am I missing ?

i have found this article, but it didnt work : Extending FreeMarkerLoginFormsProvider for custom theme attributes - #4 by mkopeyka

    @Override
    protected void createCommonAttributes(Theme theme, Locale locale, Properties messagesBundle, UriBuilder baseUriBuilder, LoginFormsPages page) {
        super.createCommonAttributes(theme, locale, messagesBundle, baseUriBuilder, page);
        attributes.put("customCommonAttribute", "Custom Common Value");
    }```

I’m using docker.
Set the your spi-login-provider like this in your Dockerfile (custom-freemarker is my Provider Id defined in the factory):
ENTRYPOINT [“/opt/keycloak/bin/kc.sh” , “–debug”, “–spi-login-provider=custom-freemarker”]
If you are not using docker just adjust it to your setup: Configuring providers - Keycloak

My Factory:

public class CustomFreeMarkerLoginFormsProviderFactory extends FreeMarkerLoginFormsProviderFactory {

    @Override
    public LoginFormsProvider create(final KeycloakSession session) {
        return new CustomFreeMarkerLoginFormsProvider(session);
    }

    @Override
    public String getId() {
        return "custom-freemarker";
    }
}

I haven’t had a chance to update login.ftl to check, but I was able to extend the FreeMarkerLoginFOrmsProviderFactory and FreeMarkerLoginFormsProvider successfully.
I believe what you need is to add the file under resources\META-INF\service
org.keycloak.forms.login.LoginFormsProviderFactory
the contents are then the full classname of your factory.
FYI - I am using docker also, but did NOT change my spi-login-provider in the command line

If you get the source, you will see this is done in the testSuite - testsuite\integration-arquillian\servers\auth-server\services\testsuite-providers\src\main\resources\META-INF\services