p2-inc / keycloak-magic-link

Magic Link Authentication for Keycloak
https://phasetwo.io
Other
222 stars 44 forks source link

Encoding of messages_xx.properties #9

Closed hookenful closed 1 year ago

hookenful commented 1 year ago

Hello there!

I am struggling to make working email template with cyrillic translation messages.

magicLinkSubject=Регистрация в program
emailTemplateProvider
          .setRealm(realm)
          .setUser(user)
          .setAttribute("realmName", realmName)
          .send("magicLinkSubject", subjAttr, "magic-link-email.ftl", bodyAttr);

When trying to do with default file encoding, I was getting question marks instead cyrillic characters, eg: ?????? ? program.

After I did some transformations of the file, I've got that subjectFormatKey stopped to be used from resourse's file and instead it is using just arg's passed string "magicLinkSubject" in subject of sent email. So that fixed my initial problem with using messages.properties file, I've just written plain subject instead format key

 emailTemplateProvider
          .setRealm(realm)
          .setUser(user)
          .setAttribute("realmName", realmName)
          .send("Регистрация в program", subjAttr, "magic-link-email.ftl", bodyAttr);

But I am not satisfied, because I think this solution is not correct, can you help me to make it working using messages_xx.resources file?

Thanks for any help!

hookenful commented 1 year ago

And I have more, not related question.

What is the purpose of having templates/html and templates/text as they both have output_format="plainText" ?

xgp commented 1 year ago

@hookenful What version of keycloak are you trying this with? I am aware of some problems loading the templates and messages_xx.properties files in 19.x.

hookenful commented 1 year ago

@hookenful What version of keycloak are you trying this with? I am aware of some problems loading the templates and messages_xx.properties files in 19.x.

We are using 19.0.2 which has recent hotfix from nightly build for missing templates, so templates are loading fine, but the problem is with cyrillic encoding when subjectFormatKey maps with propertie's messages_xx.properties value.

xgp commented 1 year ago

@hookenful Thanks for the detail. I will test this in the next couple of days.

xgp commented 1 year ago

Never able to reproduce. Closing due to inactivity.