-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle token error responses, extract some common code
- Loading branch information
Showing
7 changed files
with
108 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
wonderwalled-common/src/main/kotlin/io/nais/common/Config.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
package io.nais.common | ||
|
||
import com.natpryce.konfig.Configuration | ||
import com.natpryce.konfig.ConfigurationProperties.Companion.systemProperties | ||
import com.natpryce.konfig.EnvironmentVariables | ||
import com.natpryce.konfig.Key | ||
import com.natpryce.konfig.intType | ||
import com.natpryce.konfig.overriding | ||
import com.natpryce.konfig.stringType | ||
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk | ||
|
||
private val config = | ||
systemProperties() overriding | ||
EnvironmentVariables() | ||
|
||
data class AppConfig( | ||
data class Config( | ||
val port: Int = config.getOrElse(Key("application.port", intType), 8080), | ||
val auth: AuthClientConfig = AuthClientConfig(config), | ||
val auth: Auth = Auth(config), | ||
// optional, generally only needed when running locally | ||
val ingress: String = config.getOrElse(key = Key("login.ingress", stringType), default = ""), | ||
) | ||
) { | ||
init { | ||
AutoConfiguredOpenTelemetrySdk.initialize() | ||
} | ||
|
||
data class Auth( | ||
val tokenEndpoint: String, | ||
val tokenExchangeEndpoint: String, | ||
val tokenIntrospectionEndpoint: String, | ||
) { | ||
constructor(config: Configuration) : this( | ||
tokenEndpoint = config[Key("nais.token.endpoint", stringType)], | ||
tokenExchangeEndpoint = config[Key("nais.token.exchange.endpoint", stringType)], | ||
tokenIntrospectionEndpoint = config[Key("nais.token.introspection.endpoint", stringType)], | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.