Integrate AWS secret Manager to Jboss and Tomcat servers to retrieve database credentials

Discussão em 'StackOverflow' iniciado por Stack, Julho 12, 2021.

  1. Stack

    Stack Membro Participativo

    I have deployed project WAR files in both Tomcat and Jboss servers and database source is fetched through JNDI.

    Following are the sample DB configuration defined in server containers. I have hardcoded database credentials in those files.

    Jboss 7 daatabase configuration defined in configuration xml file

    <datasources>
    <datasource jndi-name="java:/test" pool-name="test" statistics-enabled="true">
    <connection-url>jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull</connection-url>
    <driver>mysql</driver>
    <pool>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>60</max-pool-size>
    </pool>
    <security>
    <user-name>abc</user-name>
    <password>abc123</password>
    </security>
    <validation>
    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
    <validate-on-match>true</validate-on-match>
    <background-validation>false</background-validation>
    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
    </validation>
    <timeout>
    <blocking-timeout-millis>5000</blocking-timeout-millis>
    <idle-timeout-minutes>35</idle-timeout-minutes>
    <query-timeout>300</query-timeout>
    </timeout>
    </datasource>
    <datasources>


    Tomcat 8 database configurations in conf/context.xml

    <Context>

    <!-- Default set of monitored resources. If one of these changes, the -->
    <!-- web application will be reloaded. -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <Resource name="datasource/test" auth="Container"
    type="com.mchange.v2.c3p0.ComboPooledDataSource"
    factory="org.apache.naming.factory.BeanFactory"
    user="abc"
    password="abc123"
    jdbcUrl="jdbc:mysql://localhost:3306/jacplus"
    driverClass="com.mysql.jdbc.Driver"
    minPoolSize="2"
    initialPoolSize="30"
    maxPoolSize="50"
    idleConnectionTestPeriod="600"
    acquireRetryAttempts="30"/>

    </Context>


    As a security concern, I got a requirement to move these hardcoded credentials to AWS secret Manager and retrieve them in runtime. All posts I have seen mention using the API/SDK directly from code, none I have found say anything about server integration.

    My question is there a way to integrate AWS secret manager to both tomcat and JBoss application servers and use data source as JNDI?

    Continue reading...

Compartilhe esta Página