## COPY keycloak.cli /opt/jboss/startup-scripts/keycloak.cli
#cp -R /opt/custom/deployments/* /opt/jboss/keycloak/standalone/deployments/
embed-server --server-config=standalone-ha.xml --std-out=echo 
batch

# Haproxy in front
#/subsystem=keycloak-server/spi=x509cert-lookup/provider=haproxy:remove
#/subsystem=keycloak-server/spi=x509cert-lookup:write-attribute(name=default-provider, value="haproxy")
#/subsystem=keycloak-server/spi=x509cert-lookup/provider=default:remove
#/subsystem=keycloak-server/spi=x509cert-lookup/provider=haproxy:add(enabled=true,properties={ sslClientCert => "SSL_CLIENT_CERT", sslCertChainPrefix => "CERT_CHAIN", certificateChainLength => "10"})

# Add avatar
/subsystem=keycloak-server/:write-attribute(name=providers,value=[ classpath:${jboss.home.dir}/providers/*,module:deployment.avatar-minio-extension-bundle ])
/subsystem=keycloak-server/spi=avatar-storage/:add
/subsystem=keycloak-server/spi=avatar-storage/provider=avatar-storage-minio/:add(enabled=true)


#:reload



run-batch 
stop-embedded-server


#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/spi=x509cert-lookup:write-attribute(name=default-provider, value="haproxy")'            
#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/spi=x509cert-lookup/provider=default:remove'
#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/spi=x509cert-lookup/provider=haproxy:add(enabled=true,properties={ sslClientCert => "SSL_CLIENT_CERT", sslCertChainPrefix => "CERT_CHAIN", certificateChainLength => "10"})'           
#./jboss-cli.sh --connect --command=':reload'

#<spi name="x509cert-lookup">
#    <default-provider>haproxy</default-provider>
#    <provider name="haproxy" enabled="true">
#        <properties>
#            <property name="sslClientCert" value="SSL_CLIENT_CERT"/>
#            <property name="sslCertChainPrefix" value="CERT_CHAIN"/>
#            <property name="certificateChainLength" value="10"/>
#        </properties>
#    </provider>
#</spi>

# <subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
#   <providers>
#     <provider>
#       module:deployment.avatar-minio-extension-bundle
#     </provider>
#   </providers>
#   <spi name="avatar-storage">
#     <provider name="avatar-storage-minio" enabled="true"/>
#   </spi>

#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheThemes,value=false)'
#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheTemplates,value=false)'
#./jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value=-1)'
#./jboss-cli.sh --connect --command='reload'