Andy Alorwu
02/15/2023, 12:20 PMapplication.conf
file when using ktor.
I’m trying this for the first time so pardon me. I’ve created a conf file as follows:
ktor {
deployment {
port = 8080
}
application {
modules = [ com.example.ApplicationKt.module ]
}
}
jwt {
"secret" = ${m_secret}
"issuer" = "my_issuer"
….
}
I would like to extract the values for the jwt
properties into an environment file so that i don’t publish my secrets into version control. What’s the best way to do this? I tried accessing the value of ${m_secret}
from a dev.env
file which I set as m_secret="secret"
but that didn’t work as I run into the following error: Could not resolve substitution to a value: ${m_secret}
. Thanks in advance.Dominik Sandjaja
02/15/2023, 1:16 PMdev.env
file is correctly used for variable substitution? Have you tried running with a direct environment variable?Goetz Markgraf
02/15/2023, 2:50 PMm_secret
is the value. I guess, you should use the key: secret
, probably with its path: jwt.secret
.Adam Proschek
02/17/2023, 5:48 AM.conf
file is just a text file, so I don’t think it’ll grab the actual environment variable. Those variables are used in Security.kt
in the default project setup, so you could access the environment variables there instead.Andy Alorwu
02/17/2023, 7:34 AMRun/Debug Configurations
I had to enable the use of the EnvFile
and attach my dev.env
file as shown in the attached image. After that, I could pass the environment variables from my dev.env
file.