Skip to content

Commit

Permalink
feat: add JWT verify (jvm) in common module, removed verify from Locl…
Browse files Browse the repository at this point in the history
…KMS and AmazonKMS
  • Loading branch information
robertmathew committed Sep 8, 2024
1 parent ee2457f commit 89cf7f6
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 80 deletions.
25 changes: 0 additions & 25 deletions modules/amazon-kms/src/main/kotlin/AmazonKms.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,6 @@ class AmazonKms {
return encodedHeader + "." + encodedPayload + "." + signature
}

fun verify(token: String, keyId: String): Boolean {
try {
val parts = token.split(".")
if (parts.size != 3) {
return false // Invalid token format
}

val header = parts[0]
val payload = parts[1]
val signature = parts[2]

val verificationRequest = VerifyRequest.builder().keyId(keyId)
.message(SdkBytes.fromString(header + "." + payload, StandardCharsets.UTF_8))
.signature(SdkBytes.fromByteArray(Base64.getUrlDecoder().decode(signature)))
.signingAlgorithm(SigningAlgorithmSpec.ECDSA_SHA_256) // Adjust if needed
.build()

val verificationResponse = kmsClient.verify(verificationRequest)

return verificationResponse.signatureValid()
} catch (e: Exception) {
return false
}
}

private fun createKey(): String {
val request = CreateKeyRequest.builder().keyUsage(KeyUsageType.SIGN_VERIFY)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.sphereon.oid.fed.kms.local.encryption.AesEncryption
import com.sphereon.oid.fed.kms.local.extensions.toJwkAdminDto
import com.sphereon.oid.fed.kms.local.jwk.generateKeyPair
import com.sphereon.oid.fed.kms.local.jwt.sign
import com.sphereon.oid.fed.kms.local.jwt.verify
import com.sphereon.oid.fed.openapi.models.JWTHeader
import com.sphereon.oid.fed.openapi.models.Jwk
import com.sphereon.oid.fed.openapi.models.JwkAdminDTO
Expand Down Expand Up @@ -37,8 +36,4 @@ class LocalKms {

return sign(header = mHeader, payload = payload, key = jwkObject)
}

fun verify(token: String, jwk: Jwk): Boolean {
return verify(jwt = token, key =jwk)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ import com.sphereon.oid.fed.openapi.models.Jwk
import kotlinx.serialization.json.JsonObject

expect fun sign(payload: JsonObject, header: JWTHeader, key: Jwk): String
expect fun verify(jwt: String, key: Jwk): Boolean
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,3 @@ actual fun sign(
.setProtectedHeader(JSON.parse<Any>(Json.encodeToString(header)))
.sign(key = privateKey, signOptions = opts)
}

@ExperimentalJsExport
@JsExport
actual fun verify(
jwt: String,
key: Any,
opts: Map<String, Any>
): Boolean {
return Jose.jwtVerify(jwt, key, opts)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.sphereon.oid.fed.kms.local.jwt

import com.nimbusds.jose.*
import com.nimbusds.jose.JOSEObjectType
import com.nimbusds.jose.JWSAlgorithm
import com.nimbusds.jose.JWSHeader
import com.nimbusds.jose.JWSSigner
import com.nimbusds.jose.crypto.ECDSASigner
import com.nimbusds.jose.crypto.ECDSAVerifier
import com.nimbusds.jose.jwk.ECKey
import com.nimbusds.jwt.JWTClaimsSet
import com.nimbusds.jwt.SignedJWT
Expand All @@ -28,21 +30,6 @@ actual fun sign(
return signedJWT.serialize()
}

actual fun verify(
jwt: String, key: Jwk
): Boolean {
try {
val jwkJsonString = Json.encodeToString(key)
val ecKey = ECKey.parse(jwkJsonString)
val verifier: JWSVerifier = ECDSAVerifier(ecKey)
val signedJWT = SignedJWT.parse(jwt)
val verified = signedJWT.verify(verifier)
return verified
} catch (e: Exception) {
throw Exception("Couldn't verify the JWT Signature: ${e.message}", e)
}
}

fun JWTHeader.toJWSHeader(): JWSHeader {
val type = typ
return JWSHeader.Builder(JWSAlgorithm.parse(alg)).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,4 @@ class JoseJwtTest {
)
assertTrue { signature.startsWith("ey") }
}

@Test
fun verifyTest() {
val key = ECKeyGenerator(Curve.P_256).keyID("key1").algorithm(Algorithm("ES256")).generate()
val jwk = key.toString()
val entityStatement = EntityConfigurationStatement(
iss = "test", sub = "test", exp = 111111, iat = 111111, jwks = JsonObject(mapOf())
)
val payload: JsonObject = Json.encodeToJsonElement(entityStatement) as JsonObject
val signature = sign(
payload,
JWTHeader(alg = JWSAlgorithm.ES256.toString(), typ = "JWT", kid = key.keyID),
Json.decodeFromString<Jwk>(jwk)
)
assertTrue { verify(signature, Json.decodeFromString<Jwk>(jwk)) }
}
}
1 change: 1 addition & 0 deletions modules/openid-federation-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ kotlin {
dependencies {
implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
runtimeOnly("io.ktor:ktor-client-cio-jvm:$ktorVersion")
implementation("com.nimbusds:nimbus-jose-jwt:9.40")
}
}
val jvmTest by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.sphereon.oid.fed.common.crypto

expect fun verify(jwtToken: String): Boolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.sphereon.oid.fed.common.crypto

actual fun verify(jwtToken: String): Boolean {
TODO("Not yet implemented")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.sphereon.oid.fed.common.crypto

import com.nimbusds.jose.JOSEException
import com.nimbusds.jose.crypto.ECDSAVerifier
import com.nimbusds.jose.crypto.RSASSAVerifier
import com.nimbusds.jose.jwk.ECKey
import com.nimbusds.jose.jwk.JWK
import com.nimbusds.jose.jwk.RSAKey
import com.nimbusds.jwt.SignedJWT
import com.sphereon.oid.fed.common.logging.Logger
import com.sphereon.oid.fed.openapi.models.EntityConfigurationStatement
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import java.text.ParseException

actual fun verify(jwtToken: String): Boolean {
return try {
val json = Json { ignoreUnknownKeys = true }
val signedJWT = SignedJWT.parse(jwtToken)
val payload = json.decodeFromString<EntityConfigurationStatement>(signedJWT.payload.toString())

//Filtering key from array of jwks
val jwkArray = payload.jwks.get("keys")?.jsonArray
val filteredJwk = jwkArray?.filter {
val value: String = it.jsonObject.get("kid")?.jsonPrimitive?.content ?: ""
value == signedJWT.header.keyID
}

val jwk: JWK = JWK.parse(Json.encodeToString(filteredJwk?.get(0)))

when (jwk) {
is RSAKey -> {
val publicKey = jwk.toRSAPublicKey()
val verifier = RSASSAVerifier(publicKey)
signedJWT.verify(verifier)
}

is ECKey -> {
val publicKey = jwk.toECPublicKey()
val verifier = ECDSAVerifier(publicKey)
signedJWT.verify(verifier)
}

else -> false // Unsupported key type
}
} catch (e: ParseException) {
Logger.error("OIDF", "Exception", e)
false
} catch (e: JOSEException) {
Logger.error("OIDF", "Exception", e)
false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sphereon.oid.fed.common.crypto

import kotlin.test.Test
import kotlin.test.assertTrue

class JwtVerifyTest {

@Test
fun verifyTest() {
val jwt =
"eyJraWQiOiJkZWZhdWx0UlNBU2lnbiIsInR5cCI6ImVudGl0eS1zdGF0ZW1lbnQrand0IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJodHRwczovL29pZGMucmVnaXN0cnkuc2Vydml6aWNpZS5pbnRlcm5vLmdvdi5pdCIsIm1ldGFkYXRhIjp7ImZlZGVyYXRpb25fZW50aXR5Ijp7ImZlZGVyYXRpb25fZmV0Y2hfZW5kcG9pbnQiOiJodHRwczovL29pZGMucmVnaXN0cnkuc2Vydml6aWNpZS5pbnRlcm5vLmdvdi5pdC9mZXRjaCIsImZlZGVyYXRpb25fcmVzb2x2ZV9lbmRwb2ludCI6Imh0dHBzOi8vb2lkYy5yZWdpc3RyeS5zZXJ2aXppY2llLmludGVybm8uZ292Lml0L3Jlc29sdmUiLCJmZWRlcmF0aW9uX3RydXN0X21hcmtfc3RhdHVzX2VuZHBvaW50IjoiaHR0cHM6Ly9vaWRjLnJlZ2lzdHJ5LnNlcnZ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oInHS5wywsBKtKSjQfK34Se1pthp_9sECtTux7DDgCCedd10JnLD7uGSTgb_aWwFvL7s3obDKMlbtE0hr54D11k8Ch150im6L-cds_vmMvt3RavBuZVBVS7XBcMCnzuRy2SI6Fv5wCyqLkyeFJ91jslj96nq1RF10cWCtnjg"
assertTrue { verify(jwt) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.sphereon.oid.fed.services.kms

import com.sphereon.oid.fed.kms.local.AmazonKms
import com.sphereon.oid.fed.openapi.models.JWTHeader
import com.sphereon.oid.fed.openapi.models.Jwk
import com.sphereon.oid.fed.openapi.models.JwkAdminDTO
import kotlinx.serialization.json.JsonObject

Expand All @@ -18,7 +17,7 @@ class AmazonKmsClient : KmsClient {
return amazonKms.sign(header, payload, keyId)
}

override fun verify(token: String, keyId: String?, jwk: Jwk?): Boolean {
return amazonKms.verify(token, keyId!!)
override fun verify(token: String): Boolean {
return com.sphereon.oid.fed.common.crypto.verify(token)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ object KmsService {
interface KmsClient {
fun generateKeyPair(): JwkAdminDTO
fun sign(header: JWTHeader, payload: JsonObject, keyId: String): String
fun verify(token: String, keyId: String?, jwk: Jwk?): Boolean
fun verify(token: String): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LocalKmsClient : KmsClient {
return localKms.sign(header, payload, keyId)
}

override fun verify(token: String, keyId: String?, jwk: Jwk?): Boolean {
return localKms.verify(token, jwk!!)
override fun verify(token: String): Boolean {
return com.sphereon.oid.fed.common.crypto.verify(token)
}
}

0 comments on commit 89cf7f6

Please sign in to comment.