@@ -225,11 +225,22 @@ def _get_approved_attributes(self, idp, idp_policy, sp_entity_id, state):
225
225
attribute_filter = []
226
226
for aconv in attrconvs :
227
227
if aconv .name_format == name_format :
228
- attribute_filter = list (idp_policy .restrict (aconv ._to , sp_entity_id , idp .metadata ).keys ())
228
+ all_attributes = {v : None for v in aconv ._fro .values ()}
229
+ attribute_filter = list (idp_policy .restrict (all_attributes , sp_entity_id , idp .metadata ).keys ())
230
+ break
229
231
attribute_filter = self .converter .to_internal_filter (self .attribute_profile , attribute_filter )
230
232
satosa_logging (logger , logging .DEBUG , "Filter: %s" % attribute_filter , state )
231
233
return attribute_filter
232
234
235
+ def _filter_attributes (self , idp , internal_response , context ,):
236
+ idp_policy = idp .config .getattr ("policy" , "idp" )
237
+ if idp_policy :
238
+ approved_attributes = self ._get_approved_attributes (idp , idp_policy , internal_response .requester ,
239
+ context .state )
240
+ attributes = {k : v for k , v in internal_response .attributes .items () if k in approved_attributes }
241
+
242
+ return attributes
243
+
233
244
def _handle_authn_response (self , context , internal_response , idp ):
234
245
"""
235
246
See super class satosa.frontends.base.FrontendModule
@@ -246,6 +257,7 @@ def _handle_authn_response(self, context, internal_response, idp):
246
257
request_state = self .load_state (context .state )
247
258
248
259
resp_args = request_state ["resp_args" ]
260
+ internal_response .attributes = self ._filter_attributes (idp , internal_response , context )
249
261
ava = self .converter .from_internal (self .attribute_profile , internal_response .attributes )
250
262
251
263
auth_info = {}
0 commit comments