简体   繁体   中英

CLI Scripting - Enable provider using environment properties

With Keycloak installation 9.0.2.

From keycloak documentation a SPI and provider can be configured the following way within a CLI script:

**/spi=dblock/:add(default-provider=jpa)
**/spi=dblock/provider=jpa/:add(properties={lockWaitTimeout => "900" },enabled=true)

With the goal of settings the properties and enabling the provider using environment properties I have done in my script the following (adapting from the public documentation case):

**/spi=dblock/:add(default-provider=jpa)
**/spi=dblock/provider=jpa/:add(properties={lockWaitTimeout => "${env.LOCK_WAIT_TIMEOUT:900}" },enabled="${env.ENABLE_JPA:true}")

Running my server in standalone mode it leads to the following configuration in my standalone.xml file:

...
<spi name="dblock">
    <provider name="jpa" enabled="false">
        <properties>
            <property name="lockWaitTimeout" value="${env.LOCK_WAIT_TIMEOUT:900}"/>
        </properties>
    </provider>
</spi>
...

Properties are evaluated correctly with environment variable, but setting the enabled value as described above will always result to it statically being evaluated to false.

Is it not possible to use environment variable at this level and have anyone an idea how I should do so? Thanks a lot for your time.

I encountered the same issue and spent quite some time attempting to get this to work. Unfortunately, its not possible.

According to this Bugreport you can use EnvironmentDependentProviderFactory.isSupported() as an alternative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM