Skip to content

Commit e43104d

Browse files
committed
Delegate dict deserialation to the InternalData constructor
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent bb61471 commit e43104d

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/satosa/internal.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,21 @@ def from_dict(cls, data):
164164
:param data: A dict representation of an InternalData object
165165
:return: An InternalData object
166166
"""
167-
auth_info = data.get("auth_info", AuthenticationInformation())
167+
auth_info = AuthenticationInformation.from_dict(
168+
data.get("auth_info", {})
169+
)
168170
instance = cls(
169-
auth_info=AuthenticationInformation.from_dict(auth_info),
171+
auth_info=auth_info,
170172
requester=data.get("requester"),
171173
requester_name=data.get("requester_name"),
172174
subject_id=data.get("subject_id"),
173175
subject_type=data.get("subject_type"),
174176
attributes=data.get("attributes"),
177+
user_id=data.get("user_id"),
178+
user_id_hash_type=data.get("hash_type"),
179+
name_id=data.get("name_id"),
180+
approved_attributes=data.get("approved_attributes"),
175181
)
176-
177-
if instance.attributes is None:
178-
approved_attributes = data.get("approved_attributes")
179-
instance.attributes = (
180-
approved_attributes
181-
if approved_attributes is not None
182-
else {}
183-
)
184-
if instance.subject_type is None:
185-
instance.subject_type = data.get("subject_type")
186-
if instance.subject_id is None:
187-
instance.subject_id = data.get("user_id") or data.get("name_id")
188182
return instance
189183

190184
@property

0 commit comments

Comments
 (0)