From d7d4f90b516a4ac2e624a503e86d1b6e36f4c548 Mon Sep 17 00:00:00 2001 From: mikeplotean <101570226+mikeplotean@users.noreply.github.com> Date: Fri, 5 May 2023 16:00:52 +0300 Subject: [PATCH] chore: persist revocation data (#304) --- k8s/deployment-dev.yaml | 16 ++++++++++++++++ k8s/deployment-prod.yaml | 16 ++++++++++++++++ .../kotlin/id/walt/services/WaltIdServices.kt | 2 ++ .../SimpleCredentialStatus2022StorageService.kt | 6 +++--- .../statuslist2021/StatusListIndexService.kt | 3 ++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/k8s/deployment-dev.yaml b/k8s/deployment-dev.yaml index 95e2014f..fcbf89b8 100644 --- a/k8s/deployment-dev.yaml +++ b/k8s/deployment-dev.yaml @@ -1,4 +1,15 @@ apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: data-volume-claim +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 100Mi +--- +apiVersion: v1 kind: ConfigMap metadata: name: signatory-config @@ -37,6 +48,8 @@ spec: mountPath: "/app/config/signatory.conf" subPath: "signatory.conf" readOnly: true + - mountPath: "/app/data/revocation" + name: data-volume args: - serve - -b @@ -59,6 +72,9 @@ spec: - key: signatory.conf path: signatory.conf name: signatory-config + - name: data-volume + persistentVolumeClaim: + claimName: data-volume-claim --- kind: Service apiVersion: v1 diff --git a/k8s/deployment-prod.yaml b/k8s/deployment-prod.yaml index a2bab9bb..37b12c29 100644 --- a/k8s/deployment-prod.yaml +++ b/k8s/deployment-prod.yaml @@ -1,4 +1,15 @@ apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: data-volume-claim +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 100Mi +--- +apiVersion: v1 kind: ConfigMap metadata: name: signatory-config @@ -37,6 +48,8 @@ spec: mountPath: "/app/config/signatory.conf" subPath: "signatory.conf" readOnly: true + - mountPath: "/app/data/revocation" + name: data-volume args: - serve - -b @@ -59,6 +72,9 @@ spec: - key: signatory.conf path: signatory.conf name: signatory-config + - name: data-volume + persistentVolumeClaim: + claimName: data-volume-claim --- kind: Service apiVersion: v1 diff --git a/src/main/kotlin/id/walt/services/WaltIdServices.kt b/src/main/kotlin/id/walt/services/WaltIdServices.kt index 464db861..4cb02e01 100644 --- a/src/main/kotlin/id/walt/services/WaltIdServices.kt +++ b/src/main/kotlin/id/walt/services/WaltIdServices.kt @@ -36,6 +36,7 @@ object WaltIdServices { const val dataDir = "data" const val keyDir = "$dataDir/key/" const val ebsiDir = "$dataDir/ebsi/" + const val revocationDir = "$dataDir/revocation" val httpLogging = false private val log = KotlinLogging.logger {} @@ -106,6 +107,7 @@ object WaltIdServices { Files.createDirectories(Path.of("$dataDir/vc/created")) Files.createDirectories(Path.of("$dataDir/vc/presented")) Files.createDirectories(Path.of(ebsiDir)) + Files.createDirectories(Path.of(revocationDir)) } fun loadConfig() = ConfigLoader.builder() diff --git a/src/main/kotlin/id/walt/signatory/revocation/simplestatus2022/SimpleCredentialStatus2022StorageService.kt b/src/main/kotlin/id/walt/signatory/revocation/simplestatus2022/SimpleCredentialStatus2022StorageService.kt index 734ffeed..b90e0ce0 100644 --- a/src/main/kotlin/id/walt/signatory/revocation/simplestatus2022/SimpleCredentialStatus2022StorageService.kt +++ b/src/main/kotlin/id/walt/signatory/revocation/simplestatus2022/SimpleCredentialStatus2022StorageService.kt @@ -2,6 +2,7 @@ package id.walt.signatory.revocation.simplestatus2022 import com.beust.klaxon.Klaxon import id.walt.common.deriveRevocationToken +import id.walt.services.WaltIdServices import id.walt.signatory.revocation.RevocationStatus import id.walt.signatory.revocation.TokenRevocationStatus import java.time.Instant @@ -13,9 +14,8 @@ import kotlin.io.path.writeText object SimpleCredentialStatus2022StorageService { private val klaxon = Klaxon() - private val revokedPath = Path("data/revoked.json").apply { - if (!exists()) - writeText(klaxon.toJsonString(RevocationList(emptyList()))) + private val revokedPath = Path("${WaltIdServices.revocationDir}/revoked.json").apply { + if (!exists()) writeText(klaxon.toJsonString(RevocationList(emptyList()))) } private fun getRevokedList() = klaxon.parse(revokedPath.readText())!!.revokedList diff --git a/src/main/kotlin/id/walt/signatory/revocation/statuslist2021/StatusListIndexService.kt b/src/main/kotlin/id/walt/signatory/revocation/statuslist2021/StatusListIndexService.kt index 3164d505..cf79c625 100644 --- a/src/main/kotlin/id/walt/signatory/revocation/statuslist2021/StatusListIndexService.kt +++ b/src/main/kotlin/id/walt/signatory/revocation/statuslist2021/StatusListIndexService.kt @@ -3,6 +3,7 @@ package id.walt.signatory.revocation.statuslist2021 import com.beust.klaxon.Klaxon import id.walt.servicematrix.ServiceProvider import id.walt.services.WaltIdService +import id.walt.services.WaltIdServices import kotlinx.serialization.Serializable import java.io.File @@ -28,7 +29,7 @@ data class StatusListIndex( ) class WaltIdStatusListIndexService : StatusListIndexService() { - private val indexPath = "data/status-list-index.json" + private val indexPath = "${WaltIdServices.revocationDir}/status-list-index.json" override fun create(): StatusListIndex = StatusListIndex(index = "0").let { createAndUpdateIndex(it)