It seems KC 12.x only supports email templates on realm level? We need per client email templates (and have deployed a themes JAR that contains the login and email templates).
Is this really not possible?
You can only change email templates at the realm level.
I wonder why that is? What might be the rationale behind that?
If that is unchangeable (and I am not going to work on a patch), then is there a way to share users across realms?
I don’t know the “why”. Probably a question for the Keycloak authors/maintainers.
You could have multiple realms that are IdPs to one primary realm, but then you’d need a mechanism to route users to their correct IdP/realm.
You could create your own providers to implement this functionality if you really need it.
Take a look at the following example to override the default provider, keycloak-extensions/spi-mail-template-override at master · zonaut/keycloak-extensions · GitHub
Is there a way to reach out to them? LIke a developers mailing list or so?
Thanks. On a first glance this looks way to overengineered for a simple “use those email templates for this client” kind of functionality.
https://groups.google.com/g/keycloak-dev
The likely result of asking them will be them suggesting:
- file a ticket in the issue tracker https://issues.jboss.org/browse/KEYCLOAK
- create a fork, implement your feature and file a MR GitHub - keycloak/keycloak: Open Source Identity and Access Management For Modern Applications and Services
- profit!
I created the ticket Keycloak-17807 but since 2 months nobody did respond to it. Possibly you want to add something I forgot to it?
The ticket looks fine. However, as I said, the Keycloak team appears to have a full roadmap already, and generally only accepts work if it is critical for a security issue, or already comes with an implemented feature and MR.
I have same issue, any update of this?
I was able to achieve this with a custom EmailTemplateProviderFactory. You can extend the FreeMarkerEmailTemplateProvider class from Keycloak and just override the getTheme method with something like this (kotlin):
override fun getTheme(): Theme {
val clientId = session.context?.client?.clientId
val clientBasedThemeName = {code to construct theme name from client id}
if (clientBasedThemeName != null) {
val theme = session.theme().getTheme(clientBasedThemeName, Theme.Type.EMAIL)
if (theme != null) {
return theme
}
}
return super.getTheme()
}