From 829ac3d2a69f4db7fbac41d46fd6d3719a6f7634 Mon Sep 17 00:00:00 2001 From: waltkb <68587968+waltkb@users.noreply.github.com> Date: Fri, 27 Oct 2023 16:39:27 +0200 Subject: [PATCH] Added policy listing endpoint --- .../id/walt/credentials/verification/PolicyManager.kt | 2 ++ .../src/main/kotlin/id/walt/verifier/VerifierApi.kt | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/waltid-credentials/src/commonMain/kotlin/id/walt/credentials/verification/PolicyManager.kt b/waltid-credentials/src/commonMain/kotlin/id/walt/credentials/verification/PolicyManager.kt index c3b84b3cc..c45b72bf9 100644 --- a/waltid-credentials/src/commonMain/kotlin/id/walt/credentials/verification/PolicyManager.kt +++ b/waltid-credentials/src/commonMain/kotlin/id/walt/credentials/verification/PolicyManager.kt @@ -19,6 +19,8 @@ object PolicyManager { "webhook" */ + fun listPolicyDescriptions() = mappedPolicies.mapValues { it.value.description } + fun registerPolicies(vararg policies: VerificationPolicy) { policies.forEach { policy -> if (mappedPolicies.containsKey(policy.name)) diff --git a/waltid-verifier/src/main/kotlin/id/walt/verifier/VerifierApi.kt b/waltid-verifier/src/main/kotlin/id/walt/verifier/VerifierApi.kt index acf9f6bb8..ebfcf140e 100644 --- a/waltid-verifier/src/main/kotlin/id/walt/verifier/VerifierApi.kt +++ b/waltid-verifier/src/main/kotlin/id/walt/verifier/VerifierApi.kt @@ -1,5 +1,6 @@ package id.walt.verifier +import id.walt.credentials.verification.PolicyManager import id.walt.credentials.verification.models.PolicyRequest import id.walt.credentials.verification.models.PolicyRequest.Companion.parsePolicyRequests import id.walt.credentials.verification.policies.JwtSignaturePolicy @@ -249,6 +250,13 @@ fun Application.verfierApi() { call.respond(HttpStatusCode.NotFound) } } + get("policy-list", { + tags = listOf("Credential Verification") + summary = "List registered policies" + response { HttpStatusCode.OK to { body>() } } + }) { + call.respond(PolicyManager.listPolicyDescriptions()) + } } } }