From 09f68b69ab27b4e47dd3c9e91f871ffd5a742995 Mon Sep 17 00:00:00 2001 From: Pasquale De Rose Date: Thu, 27 Jul 2023 19:01:53 +0200 Subject: [PATCH] Moved schemas in the appropriate directories --- pyeudiw/oauth2/dpop.py | 32 +------------------------------- pyeudiw/oauth2/schema.py | 29 +++++++++++++++++++++++++++++ pyeudiw/openid4vp/schema.py | 17 +++++++++++++++++ pyeudiw/satosa/backend.py | 2 +- pyeudiw/schema/__init__.py | 17 ----------------- 5 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 pyeudiw/oauth2/schema.py create mode 100644 pyeudiw/openid4vp/schema.py delete mode 100644 pyeudiw/schema/__init__.py diff --git a/pyeudiw/oauth2/dpop.py b/pyeudiw/oauth2/dpop.py index 96b07686..8893fb57 100644 --- a/pyeudiw/oauth2/dpop.py +++ b/pyeudiw/oauth2/dpop.py @@ -2,43 +2,13 @@ import logging import uuid -from pydantic import BaseModel, HttpUrl from pyeudiw.jwt import JWSHelper from pyeudiw.jwt.utils import unpad_jwt_payload, unpad_jwt_header from pyeudiw.tools.utils import iat_now -from typing import Literal - +from pyeudiw.oauth2.schema import (DPoPTokenHeaderSchema, DPoPTokenPayloadSchema) logger = logging.getLogger("pyeudiw.oauth2.dpop") - -class DPoPTokenHeaderSchema(BaseModel): - # header - typ: Literal["dpop+jwt"] - alg: Literal[ - "RS256", - "RS384", - "RS512", - "ES256", - "ES384", - "ES512", - "PS256", - "PS384", - "PS512", - ] - # TODO - dynamic schema loader if EC or RSA - # jwk: JwkSchema - - -class DPoPTokenPayloadSchema(BaseModel): - # body - jti: str - htm: Literal["GET", "POST", "get", "post"] - htu: HttpUrl - iat: int - ath: str - - class DPoPIssuer: def __init__(self, htu: str, token: str, private_jwk: dict): self.token = token diff --git a/pyeudiw/oauth2/schema.py b/pyeudiw/oauth2/schema.py new file mode 100644 index 00000000..0d0a233c --- /dev/null +++ b/pyeudiw/oauth2/schema.py @@ -0,0 +1,29 @@ +from pydantic import BaseModel, HttpUrl + +from typing import Literal + +class DPoPTokenHeaderSchema(BaseModel): + # header + typ: Literal["dpop+jwt"] + alg: Literal[ + "RS256", + "RS384", + "RS512", + "ES256", + "ES384", + "ES512", + "PS256", + "PS384", + "PS512", + ] + # TODO - dynamic schema loader if EC or RSA + # jwk: JwkSchema + + +class DPoPTokenPayloadSchema(BaseModel): + # body + jti: str + htm: Literal["GET", "POST", "get", "post"] + htu: HttpUrl + iat: int + ath: str \ No newline at end of file diff --git a/pyeudiw/openid4vp/schema.py b/pyeudiw/openid4vp/schema.py new file mode 100644 index 00000000..398cb36d --- /dev/null +++ b/pyeudiw/openid4vp/schema.py @@ -0,0 +1,17 @@ +from pydantic import BaseModel + +class DescriptorSchema(BaseModel): + id: str + path: str + format: str + +class PresentationSubmissionSchema(BaseModel): + definition_id: str + id: str + descriptor_map: list[DescriptorSchema] + +class ResponseSchema(BaseModel): + state: str + vp_token: str | list[str] + presentation_submission: PresentationSubmissionSchema + \ No newline at end of file diff --git a/pyeudiw/satosa/backend.py b/pyeudiw/satosa/backend.py index fa06ee58..97941a3d 100644 --- a/pyeudiw/satosa/backend.py +++ b/pyeudiw/satosa/backend.py @@ -23,7 +23,7 @@ from pyeudiw.tools.qr_code import QRCode from pyeudiw.tools.mobile import is_smartphone from pyeudiw.tools.utils import iat_now -from pyeudiw.schema import Response as ResponseValidator +from pyeudiw.openid4vp.schema import ResponseSchema as ResponseValidator from pyeudiw.sd_jwt import verify_sd_jwt diff --git a/pyeudiw/schema/__init__.py b/pyeudiw/schema/__init__.py deleted file mode 100644 index 0e652d6c..00000000 --- a/pyeudiw/schema/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -from pydantic import BaseModel - -class Descriptor(BaseModel): - id: str - path: str - format: str - -class PresentationSubmission(BaseModel): - definition_id: str - id: str - descriptor_map: list[Descriptor] - -class Response(BaseModel): - state: str - vp_token: str | list[str] - presentation_submission: PresentationSubmission - \ No newline at end of file