Computer scienceBackendKtorIntroduction to Ktor

Ktor configuration

Environment variables

Report a typo

You need to configure the application so that the JWT secret is obtained from the environment variable JWT_SECRET, if this variable exists. Otherwise, the default value is assigned.

ktor {
    application {
        modules = [ com.example.ApplicationKt.serverModule ]
    }
}

jwt {
    secret = "default secret value"

    // obtain value from environment variable
    secret = ???

    issuer = "http://0.0.0.0:8080/"
    audience = "http://0.0.0.0:8080/admin"
    realm = "Access to admin page"
}

How do you obtain secret from environment variable JWT_SECRET?

Select one option from the list

Create a free account to access the full topic