最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Get credentials dynamically and set before wildfly startup - Stack Overflow

programmeradmin0浏览0评论

Currently i am using wildly 9.0.1 server and using standalone.xml file to set database credentials. I want to fetch database credentials dynamically using jar. I am using yajsw wrapper

:: Fetch the DB_USER secret from Azure KeyVaultUtil and store it in the variable
for /f "tokens=*" %%a in ('java -cp C://MyJar.jar AzureKeyVaultUtil db-user') do set DB_USER=%%a

:: Fetch the DB_PASSWORD secret from Azure KeyVaultUtil and store it in the variable
for /f "tokens=*" %%a in ('java -cp C://MyJar.jar AzureKeyVaultUtil db-password') do set DB_PASSWORD=%%a

:: Optionally echo the values to verify
echo DB_USER: %DB_USER%
echo DB_PASSWORD: %DB_PASSWORD%

:: Start the YAJSW wrapper with the environment variables set
call java -jar wrapper.jar -c wrapper-wfly-app_Portal.conf

In my standalone.xml file, i have added following.

<user-name>${env.DB_USER}</user-name>
<password>${env.DB_PASSWORD}</password>

Now, when i run above script, it replace actual database credentials in standalone.xml file which seems to be security concerns.

I just dont want credentials to be set in standalone.xml file. is there any way i can achieve this? Any help will be appreciated.

Currently i am using wildly 9.0.1 server and using standalone.xml file to set database credentials. I want to fetch database credentials dynamically using jar. I am using yajsw wrapper

:: Fetch the DB_USER secret from Azure KeyVaultUtil and store it in the variable
for /f "tokens=*" %%a in ('java -cp C://MyJar.jar AzureKeyVaultUtil db-user') do set DB_USER=%%a

:: Fetch the DB_PASSWORD secret from Azure KeyVaultUtil and store it in the variable
for /f "tokens=*" %%a in ('java -cp C://MyJar.jar AzureKeyVaultUtil db-password') do set DB_PASSWORD=%%a

:: Optionally echo the values to verify
echo DB_USER: %DB_USER%
echo DB_PASSWORD: %DB_PASSWORD%

:: Start the YAJSW wrapper with the environment variables set
call java -jar wrapper.jar -c wrapper-wfly-app_Portal.conf

In my standalone.xml file, i have added following.

<user-name>${env.DB_USER}</user-name>
<password>${env.DB_PASSWORD}</password>

Now, when i run above script, it replace actual database credentials in standalone.xml file which seems to be security concerns.

I just dont want credentials to be set in standalone.xml file. is there any way i can achieve this? Any help will be appreciated.

Share Improve this question asked Mar 4 at 13:47 Viral ThakkarViral Thakkar 1256 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You should store credentials in Elytron subsystem Credential Store mechanism since it is indeed a good practice to not keep sensitive information in standalone.xml. Review the security guide for more information https://docs.wildfly./35/WildFly_Elytron_Security.html#CredentialStore

Also, WildFly 9 is a very old version and you should upgrade to the latest version. Moreover, in the above script you should remove the logging of the password as that's a security issue.

发布评论

评论列表(0)

  1. 暂无评论