Skip to content

Commit

Permalink
chore: persist revocation data (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean authored May 5, 2023
1 parent bc3a2a9 commit d7d4f90
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
16 changes: 16 additions & 0 deletions k8s/deployment-dev.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions k8s/deployment-prod.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/id/walt/services/WaltIdServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<RevocationList>(revokedPath.readText())!!.revokedList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit d7d4f90

Please sign in to comment.