-
Notifications
You must be signed in to change notification settings - Fork 0
Add a verifier for token status list, as well as issuer and verifier for bitstring status list. #1
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
Athan13
wants to merge
35
commits into
main
Choose a base branch
from
feature/verifier-status-list
base: main
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 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f3487a1
chore: readme
dbluhm 45f6931
feat: first attempt at verification for jwt token status list, minor …
e2a92bd
fix: basic jwt verifier implemented and tested
c4ba042
fix: create test using es256, signature verification now matches issu…
53372de
chore: cleanup
58d5de7
feat: cwb verification done and tested
a735835
feat: support for parsing referenced tokens
fec3807
chore: save progress
1ee324e
fix: slightly more functional nginx server
39cb236
fix: add nginx info
f4ea94a
fix: refactoring, functional web server container with correct pdm be…
d3f5938
fix: refactor
9f97f11
feat: web server now issues actual credentials
1cccb12
feat: verification from web server is done
049f9c2
feat: add helper methods to TokenStatusListVerifier for serialising a…
8ff624a
fix: update readme, minor refactor
c064ff4
feat: create initial bitstring status list issuer, actual issuance is…
b6a95a8
feat: implement jwt format for bitstring statuslist issuer
2436710
fix: minor fix
1d27806
feat: initial verifier for bitstring status list
28b9add
chore: rename tests
cd516c7
fix: add support for embedding proofs
8ebfebc
fix: tests for embedding proofs
d262be4
fix: bugfix, bitstring status list now supports lists with multiple-b…
d32c3b5
feat: add test for statusMessage feature
051295d
fix: add support for multibit statuses to bitstring status list
57df28a
fix: add test for advanced sign/verify for bitstring status list
3e65ff1
fix: update readme
a0f942a
Update README.md
Athan13 9399f8a
fix: refactor token status list verifier
31cd172
gerge branch 'feature/verifier-status-list' of github.com:Indicio-tec…
73a6eb2
fix: refactor bitstring status list verifier
ff512c2
fix: add serialization/deserialization to bitstring-status-list, fix …
1df4254
fix: fix docstrings
956e410
fix: fix error messages
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
feat: initial verifier for bitstring status list
untested, only supports jwts Signed-off-by: Athan Massouras <athan@indicio.tech>
- Loading branch information
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ def __init__( | |
|
||
self.payload = payload | ||
|
||
self.bit_array = bit_array | ||
self._bit_array = bit_array | ||
|
||
def establish_connection( | ||
self, | ||
|
@@ -69,6 +69,14 @@ def establish_connection( | |
assert 200 <= response.status_code < 300, f"Unable to establish connection." | ||
self.issuer_uri = issuer_uri | ||
self.encoding = status_list_format | ||
|
||
# When establishing a new connection, clear previous cached values. | ||
self.headers = None | ||
self.protected_headers = None | ||
self.unprotected_headers = None | ||
self.payload = None | ||
self._bit_array = None | ||
|
||
return response.content | ||
|
||
def jwt_verify(self, sl_response: bytes, verifier: TokenVerifier): | ||
|
@@ -87,7 +95,7 @@ def jwt_verify(self, sl_response: bytes, verifier: TokenVerifier): | |
signer in sign_jwt() in issuer.py. | ||
""" | ||
# Ensure that the format is correct | ||
assert(self.encoding != "CWT", "Please use TokenStatusListVerifier.cwt_verifier() for tokens in cwt format.") | ||
assert self.encoding != "CWT", "Please use TokenStatusListVerifier.cwt_verifier() for tokens in cwt format." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a single def verify(self, verifier: TokenVerifier):
assert self.encoding in ("JWT", "CWT"), f"Invalid value for encoding: {self.encoding}"
if self.encoding == "JWT":
return self.jwt_verify(verifier)
if self.encoding == "CWT":
return self.cwt_verify(verifier) |
||
if self.encoding is None: | ||
self.encoding = "JWT" | ||
|
||
|
@@ -125,6 +133,7 @@ def jwt_verify(self, sl_response: bytes, verifier: TokenVerifier): | |
|
||
self.headers = headers | ||
self.payload = payload | ||
self._bit_array = BitArray.load(payload["status_list"]) | ||
|
||
def cwt_verify(self, token: bytes, verifier: TokenVerifier): | ||
""" | ||
|
@@ -152,7 +161,7 @@ def cwt_verify(self, token: bytes, verifier: TokenVerifier): | |
raise ImportError("cbor extra required to use this function") from err | ||
|
||
# Ensure that the format is correct | ||
assert(self.encoding != "JWT", "Please use TokenStatusListVerifier.jwt_verifier() for tokens in jwt format.") | ||
assert self.encoding != "JWT", "Please use TokenStatusListVerifier.jwt_verifier() for tokens in jwt format." | ||
if self.encoding is None: | ||
self.encoding = "CWT" | ||
|
||
|
@@ -194,6 +203,8 @@ def cwt_verify(self, token: bytes, verifier: TokenVerifier): | |
self.unprotected_headers = unprotected_headers | ||
self.payload = payload | ||
|
||
self._bit_array = BitArray.load(payload[STATUS_LIST]) | ||
|
||
def get_status(self, idx: int) -> int: | ||
""" | ||
Returns the status of an object from the status_list in payload. | ||
|
@@ -209,14 +220,10 @@ def get_status(self, idx: int) -> int: | |
The status of the requested token. | ||
""" | ||
|
||
assert self.encoding is not None and self.payload is not None,\ | ||
assert self.encoding is not None and self.payload is not None and self._bit_array is not None,\ | ||
"Before accessing the status, please verify using jwt_verify or cwt_verify" | ||
|
||
if self.bit_array is None: | ||
status_list = self.payload["status_list"] if self.encoding == "JWT" else self.payload[STATUS_LIST] | ||
self.bit_array = BitArray.load(status_list) | ||
|
||
return self.bit_array[idx] | ||
return self._bit_array[idx] | ||
|
||
|
||
def serialize_verifier(self) -> dict: | ||
|
@@ -266,11 +273,11 @@ def deserialize_verifier(cls, seralized_verifier: dict) -> "TokenStatusListVerif | |
|
||
if new_verifier.encoding == "JWT": | ||
new_verifier.headers = seralized_verifier["headers"] | ||
new_verifier.bit_array = BitArray.load(seralized_verifier["payload"]["status_list"]) | ||
new_verifier._bit_array = BitArray.load(seralized_verifier["payload"]["status_list"]) | ||
elif new_verifier.encoding == "CWT": | ||
new_verifier.protected_headers = seralized_verifier["protected_headers"] | ||
new_verifier.unprotected_headers = seralized_verifier["unprotected_headers"] | ||
new_verifier.bit_array = BitArray.load(seralized_verifier["payload"][STATUS_LIST]) | ||
new_verifier._bit_array = BitArray.load(seralized_verifier["payload"][STATUS_LIST]) | ||
else: | ||
raise ValueError(f"Invalid encoding: was {seralized_verifier["encoding"]} but needs to be JWT or CWT") | ||
|
||
|
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.
See my comments above about the TokenStatusListVerifier; many of the same recommendations apply here.