register custom parser for XML types from an extension

63 views
Skip to first unread message

Dimitrios Michail

unread,
Dec 3, 2021, 5:28:19 PM12/3/21
to Keycloak Dev
Hi guys,

I recently started development of a keycloak extension (https://github.com/grnet/eidas-keycloak-extension) which adds support the European Union eIDAS dialect of SAML v2.0. This dialect contains a few extra xml elements at the authnrequest and a bunch of additional xml types in the response.

Unless there is already some better way of doing it, I had to adjust the class `org.keycloak.saml.processing.core.parsers.saml.assertion.SAMLAttributeValueParser` in order to add support for a few custom xml types which forced me to recreate every parser class in the hierarchy and a few more like `AssertionUtils`, etc.

I noticed that other people are also facing similar problems (KEYCLOAK-19866, KEYCLOAK-19608, KEYCLOAK-18417) and found a comment by @hmlnarik at PR#8156 which suggests:           

   "Ideally there would be a extensible mechanism that registers parsers for known XML types allowing for supplying a custom parser implementation, but that could be done in a follow-up PR." 

I can probably write this given a few good pointers.

Could someone provide some hints on the right location to load such custom parsers assuming that I write a new Spi, or perhaps suggest some better approach. My issue is that providers are usually loaded from a session, but this is more like loading a static class (parsers are all singletons). I traced the providers instantiation in class `DefaultKeycloakSessionFactory` but I am not sure that this is the right location.

Any help would be valuable.

Kind regards,
Dimitrios

Reply all
Reply to author
Forward
0 new messages