3 Replies Latest reply on Jun 7, 2018 9:52 AM by dlofthouse

    How to access configuration of custom role decoder

    pmm

      We are evaluating a possible deployment scenario where we would store the groups of a user in LDAP but the roles associated with a group in a database. It is our understanding that we need to implement a custom role decoder (implement org.wildfly.security.authz.RoleDecoder) for this. If we have a configuration like this:

       

      <custom-role-decoder name="acme-custom" module="acme-elytron" class-name="com.acme.CustomRoleDecoder">

        <configuration>

          <property name="key1" value="value1"/>

        </configuration>

      </custom-role-decoder>

       

      How do we access the configuration from inside the RoleDecoder implementation?

       

      Message was edited by: Philippe Marschall, syntax highlighting broken

        • 1. Re: How to access configuration of custom role decoder
          dlofthouse

          Currently your custom component should implement the interface 'org.wildfly.extension.elytron.Configurable'.

           

          public interface Configurable {

              void initialize(final Map<String, String> configuration);

          }

           

          This is part of the WildFly Elytron subsystem so can be found in org.wildfly.core:wildfly-elytron-integration

           

          The initialize method will be called and the configured properties passed in.

           

          We are currently making a change where the interface will be optional so instead we will just detect if the custom component contains an initialize method that takes a Map as an argument and will automatically use that.

          • 2. Re: How to access configuration of custom role decoder
            pmm

            dlofthouse  wrote:

             

            Currently your custom component should implement the interface 'org.wildfly.extension.elytron.Configurable'.

             

            public interface Configurable {

                void initialize(final Map<String, String> configuration);

            }

             

            This is part of the WildFly Elytron subsystem so can be found in org.wildfly.core:wildfly-elytron-integration

             

            The initialize method will be called and the configured properties passed in.

             

            We are currently making a change where the interface will be optional so instead we will just detect if the custom component contains an initialize method that takes a Map as an argument and will automatically use that.

            Is there somewhere some documentation that I can read up on? I found quite some information on using the built in configuration but not a whole lot on extending.

            • 3. Re: How to access configuration of custom role decoder
              dlofthouse

              My colleague has just put together this blog post for custom security realms, the information about configuration of a custom component is applicable to all of the custom component types.

               

              Creating custom security realm for WildFly Elytron · Honza

              1 of 1 people found this helpful