Allow additional attributes/beans to be pushed into Freemarker templates for login and account themes by extension developers. Now set of info pushed into templates is very limited and it is not extensible.
Developer should be able to write own extension which adds additional attributes to the Freemarker templates. Developer should have available set of informations about current request and flow (in case of login theme) to be able to prepare attributes based on it, like:
- current KeycloakSession so developer has access to things like current Realm (RealmModel), current Client who calls flow (ClientModel) etc - it is available in 3.3.x Freemarker providers
- current AuthenticationSessionModel in case of login theme (so info acquired from
KEYCLOAK-2670will be available there this way) - it is NOT available in 3.3.x Freemarker providers
- current user (in account theme, but even in login theme if user is known already) - user is available in account theme and from login it should be available from AuthenticationSessionModel probably
This mechanism should be also integrated with customizable components which show forms ( Authenticator and RequiredActionProvider), so extension developers can provide additional attributes/beans to the template if necessary from these components.
Simplest solution should be extension by subclassing current Freemarker providers, but it is not possible as they use private fields and methods, so it is necessary to copy whole code, which makes maintenance hard (BTW FreeMarkerEmailTemplateProvider has been updated and uses protected methods in 3.3.x and it is much easier to extend it now, I like it).