Skip to content

Commit

Permalink
fix: VP format (#215)
Browse files Browse the repository at this point in the history
* fix: remove legacy `9999` ports from example configuration

* fix: update vp_formats in example configuration

Used the example provided at https://openid.github.io/oid4vc-haip-sd-jwt-vc/draft-oid4vc-haip-sd-jwt-vc.html#section-7.2.7-3

* refactor: moved `VPFormat` schema to a specific file

Extracted `VPFormat` and its related schemas from `__init__.py` to a dedicated file

* refactor: moved `VPFormat` schema to a specific file

Extracted `VPFormat` and its related schemas from `__init__.py` to a dedicated file

* fix: update `VpFormats` and its related tests

* refactor: raname `vp_format.py` in `vp_formats.py`

---------

Co-authored-by: Salvatore Laiso <[email protected]>
  • Loading branch information
salvatorelaiso and Salvatore Laiso authored Dec 22, 2023
1 parent 5a54fc3 commit 0f8c1d5
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 37 deletions.
15 changes: 9 additions & 6 deletions example/satosa/pyeudiw_backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ name: OpenID4VP
config:

ui:
static_storage_url: "https://localhost:9999"
static_storage_url: "https://localhost"
template_folder: "templates" # project root
qrcode_template: "qr_code.html"
error_template: "error.html"
error_url: "https://localhost:9999/error_page.html"
error_url: "https://localhost/error_page.html"

endpoints:
pre_request: '/pre-request'
Expand Down Expand Up @@ -197,7 +197,10 @@ config:
subject_type: pairwise

vp_formats:
jwt_vp_json:
alg:
- EdDSA
- ES256K
vc+sd-jwt:
sd-jwt_alg_values:
- ES256
- ES384
kb-jwt_alg_values:
- ES256
- ES384
4 changes: 2 additions & 2 deletions pyeudiw/federation/schemas/wallet_relying_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, List
from pyeudiw.jwk.schemas.jwk import JwksSchema
from pydantic import BaseModel, HttpUrl, PositiveInt
from pyeudiw.openid4vp.schemas import VPFormat
from pyeudiw.openid4vp.schemas.vp_formats import VpFormats
from pyeudiw.presentation_exchange.schemas.oid4vc_presentation_definition import PresentationDefinition


Expand Down Expand Up @@ -63,4 +63,4 @@ class WalletRelyingParty(BaseModel):
id_token_signed_response_alg: List[SigningAlgValuesSupported]
default_acr_values: List[AcrValuesSupported]
default_max_age: PositiveInt
vp_formats: VPFormat
vp_formats: VpFormats
13 changes: 0 additions & 13 deletions pyeudiw/openid4vp/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
from enum import Enum
from typing import List
from pydantic import BaseModel

class VPSigningAlgResponseSupported(str, Enum):
eddsa = "EdDSA"
es256k = "ES256K"

class VPAlgorithmSchema(BaseModel):
alg: List[VPSigningAlgResponseSupported]

class VPFormat(BaseModel):
jwt_vp_json: VPAlgorithmSchema
21 changes: 21 additions & 0 deletions pyeudiw/openid4vp/schemas/vp_formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from enum import Enum
from typing import List
from pydantic import BaseModel, Field


class Algorithms(Enum):
es256 = "ES256"
es384 = "ES384"
es512 = "ES512"
rs256 = "RS256"
rs384 = "RS384"
rs512 = "RS512"


class VcSdJwt(BaseModel):
sd_jwt_alg_values: List[Algorithms] = Field([], alias='sd-jwt_alg_values')
kb_jwt_alg_values: List[Algorithms] = Field([], alias='kb-jwt_alg_values')


class VpFormats(BaseModel):
vc_sd_jwt: VcSdJwt = Field(..., alias='vc+sd-jwt')
13 changes: 8 additions & 5 deletions pyeudiw/tests/federation/schemas/test_entity_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@
"https://www.spid.gov.it/SpidL2",
"https://www.spid.gov.it/SpidL3"
],

"vp_formats": {
"jwt_vp_json": {
"alg": [
"EdDSA",
"ES256K"
"vc+sd-jwt": {
"sd-jwt_alg_values": [
"ES256",
"ES384"
],
"kb-jwt_alg_values": [
"ES256",
"ES384"
]
}
},
Expand Down
13 changes: 10 additions & 3 deletions pyeudiw/tests/federation/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@
'id_token_encrypted_response_enc': ["A128CBC-HS256"],
'id_token_signed_response_alg': ["ES256"],
'default_max_age': 5000,
'vp_formats': {
'jwt_vp_json': {
'alg': ["EdDSA"]
"vp_formats": {
"vc+sd-jwt": {
"sd-jwt_alg_values": [
"ES256",
"ES384"
],
"kb-jwt_alg_values": [
"ES256",
"ES384"
]
}
},
'policy_uri': ''
Expand Down
12 changes: 8 additions & 4 deletions pyeudiw/tests/openid4vp/schemas/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ def test_entity_config_payload():
"https://www.spid.gov.it/SpidL3"
],
"vp_formats": {
"jwt_vp_json": {
"alg": [
"EdDSA",
"ES256K"
"vc+sd-jwt": {
"sd-jwt_alg_values": [
"ES256",
"ES384"
],
"kb-jwt_alg_values": [
"ES256",
"ES384"
]
}
},
Expand Down
12 changes: 8 additions & 4 deletions pyeudiw/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,14 @@
"require_auth_time": True,
"subject_type": "pairwise",
"vp_formats": {
"jwt_vp_json": {
"alg": [
"EdDSA",
"ES256K"
"vc+sd-jwt": {
"sd-jwt_alg_values": [
"ES256",
"ES384"
],
"kb-jwt_alg_values": [
"ES256",
"ES384"
]
}
}
Expand Down

0 comments on commit 0f8c1d5

Please sign in to comment.