-
Notifications
You must be signed in to change notification settings - Fork 12
Remote Credential Registry #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nodh
wants to merge
8
commits into
feature/dynamic-credential-registry
Choose a base branch
from
feature/remote-credential-registry
base: feature/dynamic-credential-registry
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3920398
Credentials: Remote Metadata retrieval
nodh 108c830
Preserve ISO mdoc namespaces in metadata claims
nodh 6db43e1
Derive mdoc scheme ids for legacy store entries
nodh 8c495fb
Add deprecation notice
nodh 0bf4474
Match scalar type filters against VC-JWT type arrays
nodh a1fec15
Spell check changelog
nodh 7aee9ae
Add more deprecation notices
nodh 593a89f
Document unknown credential scheme
nodh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
...nTest/kotlin/at/asitplus/wallet/lib/ktor/openid/RemoteCredentialMetadataResolutionTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,143 @@ | ||
| package at.asitplus.wallet.lib.ktor.openid | ||
|
|
||
| import at.asitplus.testballoon.matrix.matrixSuite | ||
| import at.asitplus.wallet.lib.agent.FixedTimeClock | ||
| import at.asitplus.wallet.lib.data.ConstantIndex.CredentialRepresentation.ISO_MDOC | ||
| import at.asitplus.wallet.lib.data.ConstantIndex.CredentialRepresentation.SD_JWT | ||
| import at.asitplus.wallet.lib.data.CredentialMetadataLookup | ||
| import at.asitplus.wallet.lib.data.IsoMdocCredentialScheme | ||
| import at.asitplus.wallet.lib.data.SdJwtCredentialScheme | ||
| import at.asitplus.wallet.lib.data.toCredentialScheme | ||
| import at.asitplus.wallet.sdjwt.SdJwtVcType | ||
| import io.kotest.matchers.nulls.shouldBeNull | ||
| import io.kotest.matchers.nulls.shouldNotBeNull | ||
| import io.kotest.matchers.shouldBe | ||
| import io.kotest.matchers.types.shouldBeInstanceOf | ||
| import io.ktor.client.* | ||
| import io.ktor.client.engine.mock.* | ||
| import io.ktor.http.* | ||
|
|
||
| /** | ||
| * Verifies that SD-JWT Type Metadata documents hosted in the `credentials-collection` repository resolve through | ||
| * [RemoteCredentialMetadataRegistry]. The two JSON bodies below mirror `ehic.json` and `age-verification.json` from | ||
| * that repository; the [MockEngine] serves them at their configured URLs so the test stays hermetic (no live network). | ||
| */ | ||
| val RemoteCredentialMetadataResolutionTest by matrixSuite { | ||
|
|
||
| val base = "https://raw.githubusercontent.com/a-sit-plus/credentials-collection/main" | ||
| val ehicUrl = "$base/ehic.json" | ||
| val ageVerificationUrl = "$base/age-verification.json" | ||
|
|
||
| val ehicVct = SdJwtVcType("urn:eudi:ehic:1") | ||
| val ageVerificationVct = SdJwtVcType("eu.europa.ec.av.1") | ||
|
|
||
| fun registry() = RemoteCredentialMetadataRegistry( | ||
| httpClient = HttpClient(MockEngine { request -> | ||
| when (request.url.toString()) { | ||
| ehicUrl -> respond( | ||
| content = EHIC_JSON, | ||
| status = HttpStatusCode.OK, | ||
| headers = headersOf(HttpHeaders.CacheControl, "max-age=60"), | ||
| ) | ||
|
|
||
| ageVerificationUrl -> respond( | ||
| content = AGE_VERIFICATION_JSON, | ||
| status = HttpStatusCode.OK, | ||
| headers = headersOf(HttpHeaders.CacheControl, "max-age=60"), | ||
| ) | ||
|
|
||
| else -> respondError(HttpStatusCode.NotFound) | ||
| } | ||
| }), | ||
| clock = FixedTimeClock(0), | ||
| documentUrls = mutableMapOf( | ||
| ehicVct to ehicUrl, | ||
| ageVerificationVct to ageVerificationUrl, | ||
| ), | ||
| // ISO mDoc has no direct vct fallback, so the docType must be aliased to the document's vct. | ||
| aliases = mapOf( | ||
| CredentialMetadataLookup(ISO_MDOC, ageVerificationVct.string) to ageVerificationVct, | ||
| ), | ||
| ) | ||
|
|
||
| "EHIC SD-JWT metadata resolves remotely" { | ||
| val entry = registry().findEntry(ehicVct.string, SD_JWT).shouldNotBeNull() | ||
| entry.metadata.vct shouldBe ehicVct | ||
| entry.loadedFrom shouldBe ehicUrl | ||
|
|
||
| val scheme = entry.toCredentialScheme().shouldBeInstanceOf<SdJwtCredentialScheme>() | ||
| scheme.sdJwtType shouldBe ehicVct.string | ||
| scheme.schemaUri shouldBe ehicUrl | ||
| // All 13 claims parsed, including the nested issuing_authority.* / authentic_source.* objects, all mandatory. | ||
| scheme.claimDescriptions.size shouldBe 13 | ||
| scheme.claimDescriptions.count { it.mandatory == true } shouldBe 13 | ||
| } | ||
|
|
||
| "Age verification ISO mDoc metadata resolves remotely through an alias" { | ||
| val entry = registry().findEntry(ageVerificationVct.string, ISO_MDOC).shouldNotBeNull() | ||
| entry.metadata.vct shouldBe ageVerificationVct | ||
| entry.loadedFrom shouldBe ageVerificationUrl | ||
|
|
||
| val scheme = entry.toCredentialScheme().shouldBeInstanceOf<IsoMdocCredentialScheme>() | ||
| scheme.isoDocType shouldBe ageVerificationVct.string | ||
| scheme.isoNamespace shouldBe ageVerificationVct.string | ||
| scheme.schemaUri shouldBe ageVerificationUrl | ||
| // 11 age-over predicates; only age_over_18 is mandatory. | ||
| scheme.claimDescriptions.size shouldBe 11 | ||
| scheme.claimDescriptions.count { it.mandatory == true } shouldBe 1 | ||
| } | ||
|
|
||
| "unknown vct does not resolve" { | ||
| registry().findEntry("urn:eudi:unknown:1", SD_JWT).shouldBeNull() | ||
| } | ||
| } | ||
|
|
||
| private val EHIC_JSON = """ | ||
| { | ||
| "vct": "urn:eudi:ehic:1", | ||
| "name": "European Health Insurance Card (EHIC)", | ||
| "description": "European Health Insurance Card, issued as an SD-JWT VC.", | ||
| "vck": { "format": "dc+sd-jwt" }, | ||
| "claims": [ | ||
| { "path": ["issuing_country"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["personal_administrative_number"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["issuing_authority"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["issuing_authority", "id"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["issuing_authority", "name"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["authentic_source"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["authentic_source", "id"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["authentic_source", "name"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["document_number"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["date_of_issuance"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["date_of_expiry"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["starting_date"], "mandatory": true, "sd": "allowed" }, | ||
| { "path": ["ending_date"], "mandatory": true, "sd": "allowed" } | ||
| ] | ||
| } | ||
| """.trimIndent() | ||
|
|
||
| private val AGE_VERIFICATION_JSON = """ | ||
| { | ||
| "vct": "eu.europa.ec.av.1", | ||
| "name": "Age Verification", | ||
| "description": "Age verification attestation, issued as an ISO/IEC 18013-5 mdoc.", | ||
| "vck": { | ||
| "format": "mso_mdoc", | ||
| "isoDocType": "eu.europa.ec.av.1", | ||
| "isoNamespace": "eu.europa.ec.av.1" | ||
| }, | ||
| "claims": [ | ||
| { "path": ["eu.europa.ec.av.1", "age_over_18"], "mandatory": true }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_12"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_13"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_14"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_16"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_21"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_25"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_60"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_62"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_65"] }, | ||
| { "path": ["eu.europa.ec.av.1", "age_over_68"] } | ||
| ] | ||
| } | ||
| """.trimIndent() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.