Properly handle groups info in SAML provider
authorSimo Sorce <simo@redhat.com>
Tue, 17 Mar 2015 17:22:06 +0000 (13:22 -0400)
committerSimo Sorce <simo@redhat.com>
Wed, 18 Mar 2015 00:38:27 +0000 (20:38 -0400)
Also removes internal attributes (any attribute that starts with _

Fixes: https://fedorahosted.org/ipsilon/ticket/71

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Nathan Kinder <nkinder@redhat.com>
ipsilon/providers/saml2/auth.py

index 95751aa..ddebd8c 100644 (file)
@@ -217,9 +217,15 @@ class AuthenticateRequest(ProviderPageBase):
         mappedattrs, _ = policy.map_attributes(userattrs)
         attributes = policy.filter_attributes(mappedattrs)
 
+        if '_groups' in attributes and 'groups' not in attributes:
+            attributes['groups'] = attributes['_groups']
+
         self.debug("%s's attributes: %s" % (user.name, attributes))
 
         for key in attributes:
+            # skip internal info
+            if key[0] == '_':
+                continue
             values = attributes[key]
             if isinstance(values, dict):
                 continue