@@ -225,11 +225,22 @@ def _get_approved_attributes(self, idp, idp_policy, sp_entity_id, state):
225225 attribute_filter = []
226226 for aconv in attrconvs :
227227 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
229231 attribute_filter = self .converter .to_internal_filter (self .attribute_profile , attribute_filter )
230232 satosa_logging (logger , logging .DEBUG , "Filter: %s" % attribute_filter , state )
231233 return attribute_filter
232234
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+
233244 def _handle_authn_response (self , context , internal_response , idp ):
234245 """
235246 See super class satosa.frontends.base.FrontendModule
@@ -246,6 +257,7 @@ def _handle_authn_response(self, context, internal_response, idp):
246257 request_state = self .load_state (context .state )
247258
248259 resp_args = request_state ["resp_args" ]
260+ internal_response .attributes = self ._filter_attributes (idp , internal_response , context )
249261 ava = self .converter .from_internal (self .attribute_profile , internal_response .attributes )
250262
251263 auth_info = {}
0 commit comments