Skip to content
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

Feature/request option refactor #107

Closed
wants to merge 5 commits into from
Closed

Conversation

n0900
Copy link
Contributor

@n0900 n0900 commented Aug 12, 2024

Merges OidcSiopVerifier.RequestOptions and WalletService.RequestOptions into a single class and into a seperate file which also contains all helper functions which were used to deal with manipulating RequestOptions only.

Furthermore, after looking through https://identity.foundation/presentation-exchange/spec/v1.0.0/#input-descriptor-object again I found that InputDescriptor.schema is actually MUST and thus can be used to get our credential scheme way easier than previously. Maybe I have misread - please double check. This breaks two interop tests, namely 'EUDI AuthnRequest can be parsed' and 'Idemia Interop Request'.

@n0900 n0900 self-assigned this Aug 12, 2024
@JesusMcCloud
Copy link
Collaborator

given the interop tests are the failing ones, I'm pretty sure we made InputDescriptor.schema optional to successfully interop with other parties. Still, eve if this is the case, we should explicitly indicate it in the code

Copy link
Collaborator

@JesusMcCloud JesusMcCloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming of method required

@n0900
Copy link
Contributor Author

n0900 commented Aug 13, 2024

given the interop tests are the failing ones, I'm pretty sure we made InputDescriptor.schema optional to successfully interop with other parties. Still, eve if this is the case, we should explicitly indicate it in the code

I want to add that if we decide to keep the parameter nullable for interop, we can add an Exception to RequestOptions.fromInputParameters so that it still works. So either choice is fine.

@n0900
Copy link
Contributor Author

n0900 commented Aug 14, 2024

In order to unify OidcSiopVerifier.RequestOptions and WalletService.RequestOptions I added clock and set state to not nullable. This is not a real change since RequestOptions is an internal class and by default it got a value automatically - null has never been used.

@n0900 n0900 marked this pull request as draft August 14, 2024 14:38
@JesusMcCloud
Copy link
Collaborator

The way I read this, it seems way cleaner and makes a lot of sense. Regarding interop: Maybe warn, default to the PID schema from the implementing acts and hope for the best is a valid strategy

@n0900 n0900 force-pushed the feature/requestOptionRefactor branch from 33c8d31 to 57c23d5 Compare August 19, 2024 13:54
n0900 and others added 2 commits August 19, 2024 15:59
fix testcases

Fix naming

Unify RequestOptions

Add test file

Enforce CLA

fix CHANGELOG.md

Release/4.1.1 (#105)

* 4.1.1: fix JSON serializer

* rename kmp-crypto references to signum

* easier migration fro renamed serializers
* 4.1.1: fix JSON serializer

* rename kmp-crypto references to signum

* easier migration fro renamed serializers

(cherry picked from commit 519bb06)
@n0900 n0900 force-pushed the feature/requestOptionRefactor branch from 57c23d5 to c5b6f56 Compare August 19, 2024 13:59
@n0900 n0900 marked this pull request as ready for review August 19, 2024 14:38
@n0900
Copy link
Contributor Author

n0900 commented Aug 19, 2024

Split pull request into two. Please take a look at #109 for the second part.

Copy link
Collaborator

@JesusMcCloud JesusMcCloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for me, but I am pretty sure @nodh will tell us that the property was nullable on prupose to make interop tests green, so we he will probably request changes. The fix will probably be defaulting to EU PID if it is indeed null. Of course, this requires thorough documentation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to add context for @nodh: this was required to not make github stuck, even though it is run on the target branch. makes no sense to me, but that's the way it is

@nodh
Copy link
Contributor

nodh commented Aug 20, 2024

Fine for me, but I am pretty sure @nodh will tell us that the property was nullable on prupose to make interop tests green, so we he will probably request changes. The fix will probably be defaulting to EU PID if it is indeed null. Of course, this requires thorough documentation

Indeed, even now, the EUDIW verifier at https://verifier.eudiw.dev/pid-full generates authn requests that do not contain a schema, i.e. click on requesting specific attributes, and expand the presentation definition to

{
	"id": "33ac795e-599b-460c-ab3d-db4c1ccf73fd",
	"input_descriptors": [
		{
			"id": "eu.europa.ec.eudi.pid.1",
			"name": "EUDI PID",
			"purpose": "We need to verify your identity",
			"format": {
				"mso_mdoc": {
					"alg": [
						"ES256",
						"ES384",
						"ES512"
					]
				}
			},
			"constraints": {
				"fields": [
					{
						"path": [
							"$['eu.europa.ec.eudi.pid.1']['age_over_18']"
						],
						"intent_to_retain": false
					}
				]
			}
		}
	]
}

But we should also not default to the PID scheme (which we can't, because that's an external artifact?)

* Refactor `OidcSiopVerifier.RequestOptions` and `WalletService.RequestOptions` into one separate class `RequestOptions`
* Adds `InputParameter.toRequestOptions()` functionality

Release 4.1.1 (Bugfix Release):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But 4.1.1 is now duplicated in the changelog?

@@ -12,7 +12,7 @@ kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true

artifactVersion = 4.2.0-SNAPSHOT
artifactVersion = 4.1.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this 4.1.1 on a feature branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging error. mb

)

private fun ConstantIndex.CredentialScheme.toVcConstraint() = if (supportsVcJwt) ConstraintField(
path = listOf("$.type"), filter = ConstraintFilter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indendation seems off

credentialScheme: ConstantIndex.CredentialScheme?,
): Collection<ConstraintField> = map {
if (credentialRepresentation == ISO_MDOC) credentialScheme.toConstraintField(
it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indendation seems off


private fun ConstantIndex.CredentialScheme.toSdJwtConstraint() = if (supportsSdJwt) ConstraintField(
path = listOf("$.vct"), filter = ConstraintFilter(
type = "string", pattern = sdJwtType!!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indendation seems off

import kotlinx.datetime.Clock


data class RequestOptions(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But now not all parameters here make sense for both, SIOPv2 and OID4VCI, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OID4VCI does not use responseMode, clientMetadataUrl and encryption, however by their default values they do not interfere with this use case (nullable) and they are ignored for all OID4VCI use-cases.
The same goes for SIOPv2 and clock. Since we never use RequestOptions as object but rather access it's members directly this does not influence the usage. Additionally we can make clock transient for serialization to make sure that it is never leaked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should i add this to the variable documentation?

@@ -21,7 +21,7 @@ data class InputDescriptor(
@SerialName("format")
val format: FormatHolder? = null,
@SerialName("schema")
val schema: Collection<SchemaReference>? = null,
val schema: Collection<SchemaReference>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So (see comment) better leave it nullable?

@JesusMcCloud
Copy link
Collaborator

Fine for me, but I am pretty sure @nodh will tell us that the property was nullable on prupose to make interop tests green, so we he will probably request changes. The fix will probably be defaulting to EU PID if it is indeed null. Of course, this requires thorough documentation

Indeed, even now, the EUDIW verifier at https://verifier.eudiw.dev/pid-full generates authn requests that do not contain a schema, i.e. click on requesting specific attributes, and expand the presentation definition to

{
	"id": "33ac795e-599b-460c-ab3d-db4c1ccf73fd",
	"input_descriptors": [
		{
			"id": "eu.europa.ec.eudi.pid.1",
			"name": "EUDI PID",
			"purpose": "We need to verify your identity",
			"format": {
				"mso_mdoc": {
					"alg": [
						"ES256",
						"ES384",
						"ES512"
					]
				}
			},
			"constraints": {
				"fields": [
					{
						"path": [
							"$['eu.europa.ec.eudi.pid.1']['age_over_18']"
						],
						"intent_to_retain": false
					}
				]
			}
		}
	]
}

But we should also not default to the PID scheme (which we can't, because that's an external artifact?)

I think we need to make a general decision: do we want to be lenient or spec-conforming. This particular issue should be reported at the eudiw verifier. The simple fact that having this property simplifies processing considerably is reason enough to think that there's a very good reason why the spec demands it (assuming we did not misinterpret it).
Put differently:

Somebody is wrong on the Internet!

@n0900 n0900 removed the request for review from acrusage-iaik August 20, 2024 12:04
@n0900
Copy link
Contributor Author

n0900 commented Aug 20, 2024

Fine for me, but I am pretty sure @nodh will tell us that the property was nullable on prupose to make interop tests green, so we he will probably request changes. The fix will probably be defaulting to EU PID if it is indeed null. Of course, this requires thorough documentation

Indeed, even now, the EUDIW verifier at https://verifier.eudiw.dev/pid-full generates authn requests that do not contain a schema, i.e. click on requesting specific attributes, and expand the presentation definition to

{
	"id": "33ac795e-599b-460c-ab3d-db4c1ccf73fd",
	"input_descriptors": [
		{
			"id": "eu.europa.ec.eudi.pid.1",
			"name": "EUDI PID",
			"purpose": "We need to verify your identity",
			"format": {
				"mso_mdoc": {
					"alg": [
						"ES256",
						"ES384",
						"ES512"
					]
				}
			},
			"constraints": {
				"fields": [
					{
						"path": [
							"$['eu.europa.ec.eudi.pid.1']['age_over_18']"
						],
						"intent_to_retain": false
					}
				]
			}
		}
	]
}

But we should also not default to the PID scheme (which we can't, because that's an external artifact?)

I think we need to make a general decision: do we want to be lenient or spec-conforming. This particular issue should be reported at the eudiw verifier. The simple fact that having this property simplifies processing considerably is reason enough to think that there's a very good reason why the spec demands it (assuming we did not misinterpret it). Put differently:

Somebody is wrong on the Internet!

It turns out I was wrong on the internet since since we cannot use schema-matching according to v2.0.0 or later. We need to update our references to the presentation exchange spec

@n0900 n0900 marked this pull request as draft August 20, 2024 12:32
@n0900 n0900 closed this Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants