-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: iat disclosable #18
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "sd-jwt" | ||
version = "0.10.4" | ||
version = "0.11.0" | ||
description = "The reference implementation of the IETF SD-JWT specification." | ||
authors = ["Daniel Fett <[email protected]>"] | ||
readme = "README.md" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.10.4" | ||
__version__ = "0.11.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,4 +307,4 @@ def cb_get_issuer_key(issuer): | |
sys.exit(0) | ||
|
||
if __name__ == "__main__": | ||
run() | ||
run() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
|
||
|
||
import argparse | ||
import datetime | ||
import logging | ||
import sys | ||
|
||
from typing import Dict | ||
from pathlib import Path | ||
|
||
|
@@ -29,6 +31,19 @@ | |
# Set logging to stdout | ||
logging.basicConfig(stream=sys.stdout, level=logging.INFO) | ||
|
||
def get_value_from_disclosables(attr_name, testcase): | ||
_res = None | ||
try: | ||
_res = testcase['user_claims'][ | ||
[ | ||
k for k,v in testcase['user_claims'].items() | ||
if hasattr(k, "value") and k.value == attr_name | ||
][0] | ||
] | ||
except IndexError: | ||
pass | ||
|
||
return _res | ||
|
||
def generate_test_case_data(settings: Dict, testcase_path: Path, type: str): | ||
seed = settings["random_seed"] | ||
|
@@ -42,12 +57,22 @@ def generate_test_case_data(settings: Dict, testcase_path: Path, type: str): | |
extra_header_parameters = testcase.get("extra_header_parameters", {}) | ||
|
||
claims = {} | ||
|
||
_iat = get_value_from_disclosables("iat", testcase) | ||
|
||
iat = _iat or settings.get("iat", int(datetime.datetime.utcnow().timestamp())) | ||
exp = iat + (settings.get("exp_delta_seconds", 60) * 60) | ||
|
||
if include_default_claims: | ||
claims = { | ||
"iss": settings["identifiers"]["issuer"], | ||
"iat": settings["iat"], | ||
"exp": settings["exp"], | ||
"exp": settings.get("exp", exp) | ||
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 are some claims that if not SD then they must/should be present since are required or recommended (that' IAT is one of these, if not present as SDobj it must be included in plain |
||
} | ||
else: | ||
claims = dict() | ||
|
||
if not _iat: | ||
claims['iat'] = iat | ||
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. this must be refactored I can remove that |
||
|
||
claims.update(testcase["user_claims"]) | ||
|
||
|
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.
here I was lazy, I would have to inspect the type, like isinstance(x, SDObj)