Skip to content

Commit

Permalink
use new jdbc url
Browse files Browse the repository at this point in the history
  • Loading branch information
sechmann committed Aug 19, 2024
1 parent f634af4 commit 31e79ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import org.flywaydb.core.api.output.MigrateResult

data class DatabaseConfig(
val url: String,
val user: String,
val password: String
)

fun dataSourceFrom(databaseConfig: DatabaseConfig): HikariDataSource {
Expand All @@ -35,8 +33,6 @@ private fun hikariConfig(databaseConfig: DatabaseConfig) =
idleTimeout = IDLE_TIMEOUT
connectionTimeout = CONNECTION_TIMEOUT
maxLifetime = MAX_LIFETIME
username = databaseConfig.user
password = databaseConfig.password
initializationFailTimeout = INITIALIZATION_FAIL_TIMEOUT
}

Expand Down
21 changes: 3 additions & 18 deletions src/main/kotlin/io/nais/security/oauth2/config/EnvConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import io.nais.security.oauth2.config.EnvKey.AUTH_ACCEPTED_AUDIENCE
import io.nais.security.oauth2.config.EnvKey.AUTH_CLIENT_ID
import io.nais.security.oauth2.config.EnvKey.AUTH_CLIENT_JWKS
import io.nais.security.oauth2.config.EnvKey.AUTH_WELL_KNOWN_URL
import io.nais.security.oauth2.config.EnvKey.DB_DATABASE
import io.nais.security.oauth2.config.EnvKey.DB_HOST
import io.nais.security.oauth2.config.EnvKey.DB_PASSWORD
import io.nais.security.oauth2.config.EnvKey.DB_PORT
import io.nais.security.oauth2.config.EnvKey.DB_USERNAME
import io.nais.security.oauth2.config.EnvKey.DB_JDBC_URL
import io.nais.security.oauth2.config.EnvKey.DEFAULT_TOKEN_EXPIRY_SECONDS
import io.nais.security.oauth2.config.EnvKey.ISSUER_URL
import io.nais.security.oauth2.config.EnvKey.SUBJECT_TOKEN_ISSUERS
Expand All @@ -43,11 +39,7 @@ enum class Profile {

internal object EnvKey {
const val APPLICATION_PROFILE = "APPLICATION_PROFILE"
const val DB_HOST = "DB_HOST"
const val DB_PORT = "DB_PORT"
const val DB_DATABASE = "DB_DATABASE"
const val DB_USERNAME = "DB_USERNAME"
const val DB_PASSWORD = "DB_PASSWORD"
const val DB_JDBC_URL = "DB_JDBC_URL"
const val AUTH_ACCEPTED_AUDIENCE = "AUTH_ACCEPTED_AUDIENCE"
const val AUTH_WELL_KNOWN_URL = "AUTH_WELL_KNOWN_URL"
const val AUTH_CLIENT_JWKS = "AUTH_CLIENT_JWKS"
Expand Down Expand Up @@ -106,14 +98,7 @@ fun configByProfile(): AppConfiguration =
fun isNonProd() = Profile.PROD != konfig.getOrNull(Key(APPLICATION_PROFILE, enumType<Profile>()))

internal fun databaseConfig(): DatabaseConfig {
val hostname = konfig[Key(DB_HOST, stringType)]
val port = konfig[Key(DB_PORT, stringType)]
val name = konfig[Key(DB_DATABASE, stringType)]
return DatabaseConfig(
"jdbc:postgresql://$hostname:$port/$name",
konfig[Key(DB_USERNAME, stringType)],
konfig[Key(DB_PASSWORD, stringType)]
)
return DatabaseConfig(konfig[Key(DB_JDBC_URL, stringType)])
}

internal fun clientRegistrationAuthProperties(): ClientRegistrationAuthProperties {
Expand Down

0 comments on commit 31e79ea

Please sign in to comment.