Skip to content

Commit

Permalink
Merge pull request #160 from walt-id/trust-registry-integration
Browse files Browse the repository at this point in the history
Trust registry integration
  • Loading branch information
mikeplotean committed Mar 5, 2024
2 parents ed8d276 + 027e37a commit 2ebaf9e
Show file tree
Hide file tree
Showing 41 changed files with 871 additions and 749 deletions.
16 changes: 7 additions & 9 deletions waltid-wallet-api/config/trust.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
entra: {
issuer: {
baseUrl = "<url>"
trustRecordPath = "<path>"
}
verifier: {
baseUrl = "<url>"
trustRecordPath = "<path>"
}
issuersRecord: {
baseUrl = "<url>"
trustRecordPath = "<path>"
}
verifiersRecord: {
baseUrl = "<url>"
trustRecordPath = "<path>"
}
7 changes: 7 additions & 0 deletions waltid-wallet-api/k8s/deployment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ spec:
mountPath: "/waltid-wallet-api/config/rejectionreason.conf"
subPath: "rejectionreason.conf"
readOnly: true
- name: wallet-trust-config
mountPath: "/waltid-wallet-api/config/trust.conf"
subPath: "trust.conf"
readOnly: true
- name: wallet-push-config
mountPath: "/waltid-wallet-api/config/push.conf"
subPath: "push.conf"
Expand Down Expand Up @@ -211,6 +215,9 @@ spec:
- name: wallet-rejection-reason-config
configMap:
name: wallet-rejection-reason-config
- name: wallet-trust-config
configMap:
name: wallet-trust-config
- name: wallet-push-config
secret:
secretName: wallet-push-config-secret
Expand Down
3 changes: 3 additions & 0 deletions waltid-wallet-api/k8s/deployment-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ spec:
- name: wallet-rejection-reason-config
configMap:
name: wallet-rejection-reason-config
- name: wallet-trust-config
configMap:
name: wallet-trust-config
- name: wallet-push-config
secret:
secretName: wallet-push-config-secret
Expand Down
4 changes: 3 additions & 1 deletion waltid-wallet-api/src/main/kotlin/id/walt/webwallet/Main.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package id.walt.webwallet

import id.walt.web.controllers.issuers
import id.walt.webwallet.web.controllers.issuers
import id.walt.webwallet.config.ConfigManager
import id.walt.webwallet.config.WebConfig
import id.walt.webwallet.db.Db
Expand Down Expand Up @@ -79,6 +79,8 @@ fun Application.module() {
reports()
settings()
reasons()
trustRegistry()
silentExchange()

// DID Web Registry
didRegistry()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package id.walt.webwallet.config

data class TrustConfig(
val entra: TrustEntry? = null
val issuersRecord: TrustRecord,
val verifiersRecord: TrustRecord
) : WalletConfig {
data class TrustEntry(
val issuer: TrustItem,
val verifier: TrustItem,
) {
data class TrustItem(
val baseUrl: String,
val trustRecordPath: String,
)
}
data class TrustRecord(
val baseUrl: String,
val trustRecordPath: String,
)
}
7 changes: 0 additions & 7 deletions waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/Db.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ object Db {

// Make sure the creation order is correct (references / foreignKeys have to exist)
val tables = listOf(
Issuers,
Accounts,
Wallets,
WalletOperationHistories,
Expand Down Expand Up @@ -90,12 +89,6 @@ object Db {
SchemaUtils.create(*tables)

runBlocking {
IssuersService.add(
name = "walt.id",
description = "walt.id issuer portal",
uiEndpoint = "https://portal.walt.id/credentials?ids=",
configurationEndpoint = "https://issuer.portal.walt.id/.well-known/openid-credential-issuer"
)
AccountsService.register(request = EmailAccountRequest("Max Mustermann", "string@string.string", "string"))
AccountsService.register(request = EmailAccountRequest("Max Mustermann", "user@email.com", "password"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
package id.walt.webwallet.db.models

import kotlinx.uuid.UUID
import kotlinx.uuid.exposed.KotlinxUUIDTable
import org.jetbrains.exposed.sql.ResultRow

object Issuers : KotlinxUUIDTable("issuers") {
val name = varchar("name", 512).uniqueIndex()
val description = text("description").nullable().default("no description")
val uiEndpoint = varchar("ui", 128)
val configurationEndpoint = varchar("configuration", 256)
}

data class Issuer(
val id: UUID,
val name: String,
val description: String? = null,
val uiEndpoint: String,
val configurationEndpoint: String,
) {
constructor(result: ResultRow) : this(
id = result[Issuers.id].value,
name = result[Issuers.name],
description = result[Issuers.description],
uiEndpoint = result[Issuers.uiEndpoint],
configurationEndpoint = result[Issuers.configurationEndpoint]
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package id.walt.webwallet.db.models

import id.walt.crypto.utils.JwsUtils.decodeJws
import id.walt.webwallet.manifest.provider.ManifestProvider
import id.walt.webwallet.service.events.EventDataNotAvailable
import kotlinx.datetime.Instant
import kotlinx.datetime.toKotlinInstant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.*
import kotlinx.uuid.UUID
import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.Table
Expand Down Expand Up @@ -66,13 +64,19 @@ data class WalletCredential(
}.onFailure { it.printStackTrace() }
.getOrNull()

private fun tryParseManifest(manifest: String?) = runCatching {
fun tryParseManifest(manifest: String?) = runCatching {
manifest?.let { ManifestProvider.json.decodeFromString<JsonObject>(it) }
}.fold(onSuccess = {
it
}, onFailure = {
null
})

fun parseIssuerDid(credential: JsonObject?, manifest: JsonObject? = null) =
credential?.jsonObject?.get("issuer")?.let {
if (it is JsonObject) it.jsonObject["id"]?.jsonPrimitive?.content
else it.jsonPrimitive.content
} ?: manifest?.jsonObject?.get("input")?.jsonObject?.get("issuer")?.jsonPrimitive?.content
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package id.walt.webwallet.db.models
import kotlinx.uuid.exposed.KotlinxUUIDTable

object WalletIssuers : KotlinxUUIDTable("wallet_issuers") {
// val tenant = varchar("tenant", 128).default("")
// val accountId = kotlinxUUID("accountId").autoGenerate()
val wallet = reference("wallet", Wallets)
val issuer = reference("issuer", Issuers)
val name = varchar("name", 512)
val description = text("description").nullable().default("no description")
val uiEndpoint = varchar("ui", 128)
val configurationEndpoint = varchar("configuration", 256)
val authorized = bool("authorized").default(false)//authorized to push credentials silently

init {
// foreignKey(wallet, target = Accounts.primaryKey)
uniqueIndex(wallet, issuer)
uniqueIndex(wallet, name)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package id.walt.webwallet.seeker

import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

class DefaultCredentialTypeSeeker : Seeker<String> {
override fun get(data: JsonObject): String =
data.jsonObject["type"]?.jsonArray?.last()?.jsonPrimitive?.content ?: "n/a"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package id.walt.webwallet.seeker

import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

class DefaultDidSeeker : Seeker<String> {
override fun get(data: JsonObject): String = data.jsonObject["iss"]?.jsonPrimitive?.content ?: "n/a"
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package id.walt.webwallet.seeker

import id.walt.webwallet.db.models.WalletCredential
import kotlinx.serialization.json.JsonObject


interface Seeker<T> {
fun get(credential: WalletCredential): T
fun get(data: JsonObject): T
}
Loading

0 comments on commit 2ebaf9e

Please sign in to comment.