Skip to content

Commit

Permalink
Merge pull request #850 from walt-id/fix-issuer-metadata-cors-error
Browse files Browse the repository at this point in the history
fix issuance CORS issue, fix x5c validator test
  • Loading branch information
mikeplotean authored Dec 10, 2024
2 parents 4de8aaf + b10586f commit 66e2030
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function useIssuance(query: any) {
issuerHost = issuer;
}

const credential_issuer: { credential_configurations_supported: Array<{ types: Array<String>; }>; } = await $fetch(`${issuer}/.well-known/openid-credential-issuer`)
const credential_issuer: { credential_configurations_supported: Array<{ types: Array<String>; }>; } = await $fetch(`/wallet-api/wallet/${currentWallet.value}/exchange/resolveIssuerOpenIDMetadata?issuer=${issuer}`)
const credentialList = credentialOffer.credential_configuration_ids.map((id) => credential_issuer.credential_configurations_supported[id]);

let credentialTypes: String[] = [];
Expand Down Expand Up @@ -122,4 +122,4 @@ export async function useIssuance(query: any) {
groupedCredentialTypes,
issuerHost
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ object OpenID4VCI {
appendPathSegments(it.fullPath.trim('/'))
}.buildString() }

suspend fun resolveCIProviderMetadata(credOffer: CredentialOffer) = http.get(getCIProviderMetadataUrl(credOffer)).bodyAsText().let {
suspend fun resolveCIProviderMetadata(credOffer: CredentialOffer) = resolveCIProviderMetadata(credOffer.credentialIssuer)

suspend fun resolveCIProviderMetadata(issuerBaseUrl: String) = http.get(getCIProviderMetadataUrl(issuerBaseUrl)).bodyAsText().let {
OpenIDProviderMetadata.fromJSONString(it)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package id.walt.webwallet.web.controllers.exchange

import id.walt.oid4vc.OpenID4VCI
import id.walt.oid4vc.data.CredentialOffer
import id.walt.oid4vc.data.OpenIDProviderMetadata
import id.walt.oid4vc.data.dif.PresentationDefinition
import id.walt.oid4vc.requests.CredentialOfferRequest
import id.walt.sdjwt.SDJWTVCTypeMetadata
Expand All @@ -18,6 +20,7 @@ import io.github.smiley4.ktorswaggerui.dsl.routing.post
import io.github.smiley4.ktorswaggerui.dsl.routing.route
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.plugins.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.util.*
Expand Down Expand Up @@ -261,6 +264,21 @@ fun Application.exchange() = walletRoute {
context.respond(HttpStatusCode.BadRequest, error.message ?: "Unknown error")
}
}
get("resolveIssuerOpenIDMetadata", {
summary = "Resolved Issuer OpenID Metadata"
request {
queryParameter<String>("issuer")
}
response {
HttpStatusCode.OK to {
description = "Resolved Issuer OpenID Metadata"
body<OpenIDProviderMetadata>()
}
}
}) {
val issuer = call.request.queryParameters["issuer"] ?: throw BadRequestException("Issuer base url not set")
context.respond(HttpStatusCode.OK, OpenID4VCI.resolveCIProviderMetadata(issuer).toJSON())
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.test.assertTrue

class X5CValidatorTest {

//we don't care about the bit size of the key, it's a test case (as long as it's bigger than 512)
//we don't care about the bit size of the key, it's a test case (as long as it's bigger than 1024)
private val keyPairGenerator = KeyPairGenerator
.getInstance("RSA").apply {
initialize(2048)
Expand Down

0 comments on commit 66e2030

Please sign in to comment.