-
Notifications
You must be signed in to change notification settings - Fork 17
Mdoc Cbor support #388
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
Closed
Closed
Mdoc Cbor support #388
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cff343d
tests: added test
PascalDR 57589c1
fix: specialized exception
PascalDR 60e2740
docs: updated docstring
PascalDR 033991f
fix: missing import
PascalDR cbe763e
feat: metadata param
PascalDR e665f5e
feat: add metadata in authorization request
PascalDR f7eb1a0
feat: direct_post input normalization (#384)
Zicchio 00498e9
fix: ensure that only public keys are disclosed
PascalDR 3e4ceae
fix: handle the remote case when the jwt is directly added in the Tru…
PascalDR c4dcd0b
tests: adapted test
PascalDR 1cb412f
fix: prevent private key in metadata cleaning the keys
PascalDR e1b32ed
fix: clean metadata jwks
PascalDR 90d7f92
fix: clean metadata jwk in get_metadata
PascalDR 03b1835
tests: adapted tests
PascalDR 68246d2
Merge pull request #386 from italia/feat/client_metadata
peppelinux 239c50a
Merge pull request #385 from italia/tests/pubkey_test
peppelinux 88cac52
Merge branch 'dev' of https://github.com/italia/eudi-wallet-it-python…
PascalDR f4073e6
feat: added specialized exception
PascalDR eb7d313
fix: added methods for validation
PascalDR aac9687
fix: check format in response handler to distinguish Mdoc or SDJWT
PascalDR b4b299e
fix: jwt exp
PascalDR 065fa8d
feat: added initial mdoc support
PascalDR 82eeb54
tests: fix error messages
PascalDR d8f41e6
Merge branch 'feat/x509_handler' of https://github.com/italia/eudi-wa…
PascalDR 92fd9a9
fix: documents path
PascalDR 507ae7a
fix: function name
PascalDR b824455
fix: only verify signature
PascalDR 6d351c0
test: test mdoc too
PascalDR d06655e
Apply suggestions from code review
peppelinux 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
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 |
|---|---|---|
| @@ -1,19 +1,42 @@ | ||
| from pymdoccbor.mdoc.verifier import MdocCbor | ||
| from datetime import datetime | ||
| from pyeudiw.openid4vp.exceptions import MdocCborValidationError | ||
| import logging | ||
|
|
||
| from pyeudiw.openid4vp.vp import Vp | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
peppelinux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class VpMDocCbor(Vp): | ||
| class VpMDocCbor: | ||
| def __init__(self, data: str) -> None: | ||
| self.data = data | ||
| self.mdoc = MdocCbor() | ||
| self.parse_digital_credential() | ||
|
|
||
| def parse_digital_credential(self) -> None: | ||
| self.mdoc.load(data=self.data) | ||
| def get_documents(self) -> dict: | ||
| return self.mdoc.data_as_cbor_dict["documents"] | ||
|
|
||
| def is_revoked(self) -> bool: | ||
| return False | ||
|
|
||
| def is_expired(self) -> bool: | ||
| _val_until: str = "" | ||
| try: | ||
| _val_until = self.mdoc.data_as_cbor_dict()["issuerSigned"]["issuerAuth"]["validityInfo"].get("validUntil") | ||
| except KeyError as e: | ||
| logger.error(f'Unconsitent issuerSigned schema ["issuerSigned"]["issuerAuth"]["validityInfo"], {e}, in mdoc cbor: {self.mdoc.data_as_cbor_dict()}') | ||
| if _val_until: | ||
| exp_date = datetime.fromisoformat(_val_until) | ||
| else: | ||
| logger.warning(f"Missing issuerSigned velidUntil in mdoc cbor: {self.mdoc.data_as_cbor_dict()}") | ||
|
|
||
| def verify(self, **kwargs) -> bool: | ||
| return self.mdoc.verify() | ||
| return exp_date < datetime.now() | ||
|
|
||
| def verify_signature(self) -> None: | ||
| if self.mdoc.verify() == False: | ||
| raise MdocCborValidationError("Signature is invalid") | ||
|
|
||
| def parse_digital_credential(self) -> None: | ||
| self.mdoc.loads(data=self.data) | ||
|
|
||
| def _detect_vp_type(self) -> str: | ||
| return "mdoc_cbor" | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.