Skip to content

Commit 7ca9a80

Browse files
rohec00kiemon5ter
authored andcommitted
Updated init attributes.
1 parent dba92f8 commit 7ca9a80

File tree

1 file changed

+24
-37
lines changed

1 file changed

+24
-37
lines changed

src/satosa/backends/idpy_oidc.py

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,23 @@ class IdpyOIDCBackend(BackendModule):
2525
Backend module for OIDC and OAuth 2.0, can be directly used.
2626
"""
2727

28-
def __init__(self,
29-
outgoing,
30-
internal_attributes,
31-
config,
32-
base_url,
33-
name,
34-
external_type,
35-
user_id_attr
36-
):
28+
def __init__(self, outgoing, internal_attributes, config, base_url, name):
3729
"""
38-
:param outgoing: Callback should be called by the module after the authorization in the
39-
backend is done.
40-
:param internal_attributes: Mapping dictionary between SATOSA internal attribute names and
41-
the names returned by underlying IdP's/OP's as well as what attributes the calling SP's and
42-
RP's expects namevice.
43-
:param config: Configuration parameters for the module.
44-
:param base_url: base url of the service
45-
:param name: name of the plugin
46-
:param external_type: The name for this module in the internal attributes.
47-
4830
:type outgoing:
4931
(satosa.context.Context, satosa.internal.InternalData) -> satosa.response.Response
50-
:type internal_attributes: dict[string, dict[str, str | list[str]]]
51-
:type config: dict[str, dict[str, str] | list[str]]
32+
:type internal_attributes: dict[str, dict[str, list[str] | str]]
33+
:type config: dict[str, Any]
5234
:type base_url: str
5335
:type name: str
54-
:type external_type: str
36+
37+
:param outgoing: Callback should be called by the module after
38+
the authorization in the backend is done.
39+
:param internal_attributes: Internal attribute map
40+
:param config: The module config
41+
:param base_url: base url of the service
42+
:param name: name of the plugin
5543
"""
5644
super().__init__(outgoing, internal_attributes, base_url, name)
57-
self.name = name
58-
self.external_type = external_type
59-
self.user_id_attr = user_id_attr
6045

6146
self.client = StandAloneClient(config=config["client_config"],
6247
client_type=config["client_config"]['client_type'])
@@ -119,18 +104,20 @@ def _authn_response(self, context):
119104
try:
120105
auth_info = self.auth_info(context.request)
121106
except NotImplementedError:
122-
auth_info = AuthenticationInformation(UNSPECIFIED, str(datetime.now()), _info["issuer"])
123-
124-
internal_response = InternalData(auth_info=auth_info)
125-
internal_response.attributes = self.converter.to_internal(self.external_type,
126-
_info['userinfo'])
127-
internal_response.subject_id = _info['userinfo'][self.user_id_attr]
128-
del context.state[self.name]
129-
# return self.auth_callback_func(context, internal_response)
130-
if 'error' in _info:
131-
return _info
132-
else:
133-
return _info['userinfo']
107+
auth_info = AuthenticationInformation(auth_class_ref=UNSPECIFIED,
108+
timestamp=str(datetime.now()),
109+
issuer=_info["issuer"])
110+
111+
attributes = self.converter.to_internal(
112+
self.client.client_type, _info['userinfo'],
113+
)
114+
115+
internal_response = InternalData(
116+
auth_info=auth_info,
117+
attributes=attributes,
118+
subject_id=_info['userinfo']['sub']
119+
)
120+
return internal_response
134121

135122
def auth_info(self, request):
136123
"""

0 commit comments

Comments
 (0)