Skip to content

Commit

Permalink
Fjerner også kode som krever at konfigurasjonen er satt for sts
Browse files Browse the repository at this point in the history
  • Loading branch information
baskevold committed Dec 14, 2023
1 parent cce9128 commit 986e79f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
17 changes: 0 additions & 17 deletions src/main/kotlin/no/nav/k9/los/AccessTokenClientResolver.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
package no.nav.k9.los

import no.nav.helse.dusseldorf.ktor.auth.Client
import no.nav.helse.dusseldorf.ktor.auth.ClientSecretClient
import no.nav.helse.dusseldorf.ktor.auth.PrivateKeyClient
import no.nav.helse.dusseldorf.oauth2.client.DirectKeyId
import no.nav.helse.dusseldorf.oauth2.client.FromJwk
import no.nav.helse.dusseldorf.oauth2.client.SignedJwtAccessTokenClient
import no.nav.k9.los.Configuration.Companion.AZURE_V2_ALIAS
import no.nav.k9.los.Configuration.Companion.NAIS_STS_ALIAS

class AccessTokenClientResolver(
private val clients: Map<String, Client>) {

private val naisSts = naisStsClient().let {
NaisStsAccessTokenClient(
clientId = it.clientId(),
clientSecret = it.clientSecret,
tokenEndpoint = it.tokenEndpoint()
)
}
private val azureV2 = azureV2Client().let {
SignedJwtAccessTokenClient(
clientId = it.clientId(),
Expand All @@ -28,20 +19,12 @@ class AccessTokenClientResolver(
)
}

private fun naisStsClient() : ClientSecretClient {
val client = clients.getOrElse(NAIS_STS_ALIAS) {
throw IllegalStateException("Client[$NAIS_STS_ALIAS] må være satt opp.")
}
return client as ClientSecretClient
}

private fun azureV2Client() : PrivateKeyClient {
val client = clients.getOrElse(AZURE_V2_ALIAS) {
throw IllegalStateException("Client[$AZURE_V2_ALIAS] må være satt opp.")
}
return client as PrivateKeyClient
}

internal fun naisSts() = naisSts
internal fun azureV2() = azureV2
}
1 change: 0 additions & 1 deletion src/main/kotlin/no/nav/k9/los/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import java.time.temporal.ChronoUnit

data class Configuration(private val config: ApplicationConfig) {
companion object {
internal const val NAIS_STS_ALIAS = "nais-sts"
internal const val AZURE_V2_ALIAS = "azure-v2"
}

Expand Down

0 comments on commit 986e79f

Please sign in to comment.