Skip to content

Commit

Permalink
style: soothe linter
Browse files Browse the repository at this point in the history
  • Loading branch information
tronghn committed Jun 24, 2024
1 parent a01724c commit 79dd01c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
9 changes: 5 additions & 4 deletions wonderwalled-azure/src/main/kotlin/io/nais/AzureAdClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class AzureAdClient(
private val httpClient: HttpClient = defaultHttpClient(),
) {
private suspend inline fun fetchAccessToken(formParameters: Parameters): AccessToken =
httpClient.submitForm(
url = config.openIdConfiguration.tokenEndpoint,
formParameters = formParameters,
).body()
httpClient
.submitForm(
url = config.openIdConfiguration.tokenEndpoint,
formParameters = formParameters,
).body()

// Service-to-service access token request (client credentials grant)
suspend fun getMachineToMachineAccessToken(audience: String): AccessToken =
Expand Down
4 changes: 1 addition & 3 deletions wonderwalled-common/src/main/kotlin/io/nais/common/OpenId.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ data class OpenIdConfiguration(
private fun invalidOpenIdConfigurationException(
expected: List<String>,
got: String,
): RuntimeException {
return RuntimeException("authority does not match the issuer returned by provider: got $got, expected one of $expected")
}
): RuntimeException = RuntimeException("authority does not match the issuer returned by provider: got $got, expected one of $expected")

@JsonIgnoreProperties(ignoreUnknown = true)
data class AccessToken(
Expand Down
18 changes: 11 additions & 7 deletions wonderwalled-idporten/src/main/kotlin/io/nais/TokenXClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ class TokenXClient(
private val httpClient: HttpClient = defaultHttpClient(),
) {
private suspend inline fun fetchAccessToken(formParameters: Parameters): AccessToken =
httpClient.submitForm(
url = config.openIdConfiguration.tokenEndpoint,
formParameters = formParameters,
).body()
httpClient
.submitForm(
url = config.openIdConfiguration.tokenEndpoint,
formParameters = formParameters,
).body()

private fun clientAssertion(): String {
val now = Date.from(Instant.now())
return JWTClaimsSet.Builder()
return JWTClaimsSet
.Builder()
.issuer(config.clientId)
.subject(config.clientId)
.audience(config.openIdConfiguration.tokenEndpoint)
Expand All @@ -43,9 +45,11 @@ class TokenXClient(

private fun JWTClaimsSet.sign(): SignedJWT =
SignedJWT(
JWSHeader.Builder(JWSAlgorithm.RS256)
JWSHeader
.Builder(JWSAlgorithm.RS256)
.keyID(config.rsaKey.keyID)
.type(JOSEObjectType.JWT).build(),
.type(JOSEObjectType.JWT)
.build(),
this,
).apply {
sign(RSASSASigner(config.rsaKey.toPrivateKey()))
Expand Down

0 comments on commit 79dd01c

Please sign in to comment.