Skip to content

Commit 1ddbed4

Browse files
committedJan 27, 2025·
log stuff
1 parent 1c00141 commit 1ddbed4

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed
 

‎token-client-core/src/main/kotlin/no/nav/security/token/support/client/core/auth/ClientAssertion.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.net.URI
1414
import java.time.Instant.now
1515
import java.util.*
1616
import no.nav.security.token.support.client.core.ClientAuthenticationProperties
17-
import kotlin.DeprecationLevel.WARNING
17+
import kotlin.DeprecationLevel.ERROR
1818

1919
class ClientAssertion(private val tokenEndpointUrl : URI, private val clientId : String, private val rsaKey : RSAKey, private val expiryInSeconds : Int) {
2020
constructor(tokenEndpointUrl: URI, auth : ClientAuthenticationProperties) : this(tokenEndpointUrl, auth.clientId, auth.clientRsaKey!!, EXPIRY_IN_SECONDS)
@@ -32,7 +32,7 @@ class ClientAssertion(private val tokenEndpointUrl : URI, private val clientId :
3232
.build()).serialize()
3333
}
3434

35-
@Deprecated("Use com.nimbusds.oauth2.sdk.auth.JWTAuthentication instead", ReplaceWith("JWTAuthentication.CLIENT_ASSERTION_TYPE"), WARNING)
35+
@Deprecated("Use com.nimbusds.oauth2.sdk.auth.JWTAuthentication instead", ReplaceWith("JWTAuthentication.CLIENT_ASSERTION_TYPE"),ERROR)
3636
fun assertionType() = CLIENT_ASSERTION_TYPE
3737

3838
private fun createSignedJWT(rsaJwk : RSAKey, claimsSet : JWTClaimsSet) =

‎token-client-spring/src/main/kotlin/no/nav/security/token/support/client/spring/oauth2/OAuth2ClientRequestInterceptor.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package no.nav.security.token.support.client.spring.oauth2
22

33
import no.nav.security.token.support.client.core.oauth2.OAuth2AccessTokenService
44
import no.nav.security.token.support.client.spring.ClientConfigurationProperties
5+
import org.slf4j.LoggerFactory
56
import org.springframework.http.HttpRequest
67
import org.springframework.http.client.ClientHttpRequestExecution
78
import org.springframework.http.client.ClientHttpRequestInterceptor
@@ -22,13 +23,21 @@ import org.springframework.http.client.ClientHttpResponse
2223
class OAuth2ClientRequestInterceptor(private val properties: ClientConfigurationProperties,
2324
private val service: OAuth2AccessTokenService,
2425
private val matcher: ClientConfigurationPropertiesMatcher = object : ClientConfigurationPropertiesMatcher {}) : ClientHttpRequestInterceptor {
26+
27+
private val log = LoggerFactory.getLogger(OAuth2ClientRequestInterceptor::class.java)
28+
29+
2530
override fun intercept(req: HttpRequest, body: ByteArray, execution: ClientHttpRequestExecution): ClientHttpResponse {
31+
log.trace("Intercepting request to {}", req.uri)
2632
matcher.findProperties(properties, req.uri)?.let {
27-
service.getAccessToken(it).access_token?.let { token -> req.headers.setBearerAuth(token) }
33+
log.trace("Found properties {} for uri {}", it, req.uri)
34+
service.getAccessToken(it).access_token?.let {
35+
token -> req.headers.setBearerAuth(token)
36+
log.trace("Finished setting Authorization header with accesstoken OK")
37+
}
2838
}
2939
return execution.execute(req, body)
3040
}
31-
3241
override fun toString() = "${javaClass.simpleName} [properties=$properties, service=$service, matcher=$matcher]"
3342

3443
}

‎token-validation-core/src/main/kotlin/no/nav/security/token/support/core/validation/JwtTokenAnnotationHandler.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ open class JwtTokenAnnotationHandler(private val tokenValidationContextHolder :
5757
}
5858

5959
private fun handleRequiredIssuers(a: RequiredIssuers): Boolean {
60-
val hasToken = a.value.any { sub ->
61-
val jwtToken = getJwtToken(sub.issuer, tokenValidationContextHolder)
62-
jwtToken.isPresent && handleProtectedWithClaimsAnnotation(sub, jwtToken.get())
60+
val hasToken = a.value.any {
61+
getJwtToken(it.issuer, tokenValidationContextHolder).run {
62+
isPresent && handleProtectedWithClaimsAnnotation(it, get())
63+
}
6364
}
6465
return when {
6566
hasToken -> true

‎token-validation-filter/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
<artifactId>logback-classic</artifactId>
2828
<scope>test</scope>
2929
</dependency>
30-
<dependency>
31-
<groupId>org.jetbrains.kotlin</groupId>
32-
<artifactId>kotlin-stdlib</artifactId>
33-
</dependency>
3430
</dependencies>
3531
<build>
3632
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>

‎token-validation-jaxrs/src/test/resources/application-protected.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.web.servlet
22
no.nav.security.jwt:
33
issuers: protected
44
issuer.protected:
5-
discoveryurl: http://metadata
5+
discovery-url: http://metadata
66
accepted_audience: aud-localhost
77
debug: false

‎token-validation-ktor-v2/src/test/kotlin/no/nav/security/token/support/v2/ApplicationTest.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ class ApplicationTest {
278278
put("no.nav.security.jwt.issuers.0.issuer_name", acceptedIssuer)
279279
put(
280280
"no.nav.security.jwt.issuers.0.discoveryurl",
281-
server.wellKnownUrl(ISSUER_ID).toString()
282-
)//server.baseUrl() + "/.well-known/openid-configuration")
281+
server.wellKnownUrl(ISSUER_ID).toString())
283282
put("no.nav.security.jwt.issuers.0.accepted_audience", acceptedAudience)
284283
}
285284
}

0 commit comments

Comments
 (0)
Please sign in to comment.