aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--crowdrest/backend.py5
2 files changed, 9 insertions, 4 deletions
diff --git a/README.md b/README.md
index a7e18ae..ef6913d 100644
--- a/README.md
+++ b/README.md
@@ -61,9 +61,11 @@ How to use it
already existing in Django will be considered (i.e. user group membership in
Django will be updated to intersection of user's Crowd groups and all available
Django groups).
-
- you'd rather have this as True (default). In particular, AUTH_CROWD_STAFF_GROUP
- & AUTH_CROWD_SUPERUSER_GROUP settings depend on this.
+
+ AUTH_CROWD_GROUP_MAP = {}
+ Allows to remap group names from Crowd to Django. This may be needed to migrate
+ existing applications to Crowd authentication, when group names between Django
+ and Crowd mismatch.
_Django user will get staff flag when Crowd user is in given Crowd group_
diff --git a/crowdrest/backend.py b/crowdrest/backend.py
index 30d1f96..6b3a3b3 100644
--- a/crowdrest/backend.py
+++ b/crowdrest/backend.py
@@ -111,7 +111,10 @@ class CrowdRestBackend(object):
def sync_groups(self, user):
data = self.crowdClient.get_user_groups(user.username)
- group_names = set([x["name"] for x in data["groups"]])
+ group_names = [x["name"] for x in data["groups"]]
+ group_map = getattr(settings, "AUTH_CROWD_GROUP_MAP", {})
+ group_names = [group_map.get(x, x) for x in group_names]
+ group_names = set(group_names)
if getattr(settings, "AUTH_CROWD_SUPERUSER_GROUP", None) in group_names:
user.is_superuser = True