Don't crash if no NameIdPolicy is requested
authorRob Crittenden <rcritten@redhat.com>
Wed, 21 Oct 2015 14:52:38 +0000 (10:52 -0400)
committerPatrick Uiterwijk <puiterwijk@redhat.com>
Wed, 21 Oct 2015 18:33:25 +0000 (20:33 +0200)
This fixes two problems:

1. Logging was done before a None check was completed
2. The None check was insufficient because the whole object
   could be None

https://fedorahosted.org/ipsilon/ticket/189

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
ipsilon/providers/saml2/provider.py

index 6cbf5ab..6d46ad2 100644 (file)
@@ -254,10 +254,12 @@ class ServiceProvider(ServiceProviderConfig):
         self.load_config()
 
     def get_valid_nameid(self, nip):
-        self.debug('Requested NameId [%s]' % (nip.format,))
-        if nip.format is None:
+        if nip is None or nip.format is None:
+            self.debug('No NameId requested, returning default [%s]'
+                       % SAML2_NAMEID_MAP[self.default_nameid])
             return SAML2_NAMEID_MAP[self.default_nameid]
         else:
+            self.debug('Requested NameId [%s]' % (nip.format,))
             allowed = self.allowed_nameids
             self.debug('Allowed NameIds %s' % (repr(allowed)))
             for nameid in allowed: