@@ -676,50 +676,49 @@ def parse_authn_request_response(self, xmlstr, binding, outstanding=None,
676
676
:return: An response.AuthnResponse or None
677
677
"""
678
678
679
- try :
680
- _ = self .config .entityid
681
- except KeyError :
679
+ if not getattr (self .config , 'entityid' , None ):
682
680
raise SAMLError ("Missing entity_id specification" )
683
681
684
- resp = None
685
- if xmlstr :
686
- kwargs = {
687
- "outstanding_queries" : outstanding ,
688
- "outstanding_certs" : outstanding_certs ,
689
- "allow_unsolicited" : self .allow_unsolicited ,
690
- "want_assertions_signed" : self .want_assertions_signed ,
691
- "want_response_signed" : self .want_response_signed ,
692
- "return_addrs" : self .service_urls (binding = binding ),
693
- "entity_id" : self .config .entityid ,
694
- "attribute_converters" : self .config .attribute_converters ,
695
- "allow_unknown_attributes" :
696
- self .config .allow_unknown_attributes ,
697
- 'conv_info' : conv_info
698
- }
699
- try :
700
- resp = self ._parse_response (xmlstr , AuthnResponse ,
701
- "assertion_consumer_service" ,
702
- binding , ** kwargs )
703
- except StatusError as err :
704
- logger .error ("SAML status error: %s" , err )
705
- raise
706
- except UnravelError :
707
- return None
708
- except Exception as err :
709
- logger .error ("XML parse error: %s" , err )
710
- raise
711
-
712
- if resp is None :
713
- return None
714
- elif isinstance (resp , AuthnResponse ):
715
- if resp .assertion is not None and len (
716
- resp .response .encrypted_assertion ) == 0 :
717
- self .users .add_information_about_person (resp .session_info ())
718
- logger .info ("--- ADDED person info ----" )
719
- pass
720
- else :
721
- logger .error ("Response type not supported: %s" ,
722
- saml2 .class_name (resp ))
682
+ if not xmlstr :
683
+ return None
684
+
685
+ kwargs = {
686
+ "outstanding_queries" : outstanding ,
687
+ "outstanding_certs" : outstanding_certs ,
688
+ "allow_unsolicited" : self .allow_unsolicited ,
689
+ "want_assertions_signed" : self .want_assertions_signed ,
690
+ "want_response_signed" : self .want_response_signed ,
691
+ "return_addrs" : self .service_urls (binding = binding ),
692
+ "entity_id" : self .config .entityid ,
693
+ "attribute_converters" : self .config .attribute_converters ,
694
+ "allow_unknown_attributes" :
695
+ self .config .allow_unknown_attributes ,
696
+ 'conv_info' : conv_info
697
+ }
698
+
699
+ try :
700
+ resp = self ._parse_response (xmlstr , AuthnResponse ,
701
+ "assertion_consumer_service" ,
702
+ binding , ** kwargs )
703
+ except StatusError as err :
704
+ logger .error ("SAML status error: %s" , err )
705
+ raise
706
+ except UnravelError :
707
+ return None
708
+ except Exception as err :
709
+ logger .error ("XML parse error: %s" , err )
710
+ raise
711
+
712
+ if not isinstance (resp , AuthnResponse ):
713
+ logger .error ("Response type not supported: %s" ,
714
+ saml2 .class_name (resp ))
715
+ return None
716
+
717
+ if (resp .assertion and len (resp .response .encrypted_assertion ) == 0 and
718
+ resp .assertion .subject .name_id ):
719
+ self .users .add_information_about_person (resp .session_info ())
720
+ logger .info ("--- ADDED person info ----" )
721
+
723
722
return resp
724
723
725
724
# ------------------------------------------------------------------------
0 commit comments