diff --git a/apricot/oauth/keycloak_client.py b/apricot/oauth/keycloak_client.py index 8c2f58d..a4d939a 100644 --- a/apricot/oauth/keycloak_client.py +++ b/apricot/oauth/keycloak_client.py @@ -53,9 +53,9 @@ def groups(self) -> list[JSONDict]: # If group_gid exists then set the cache to the same value # This ensures that any groups without a `gid` attribute will receive a # UID that does not overlap with existing groups - if group_gid := group_dict["attributes"]["gid"]: + if (group_gid := group_dict["attributes"]["gid"]) and len(group_dict["attributes"]["gid"]) == 1: self.uid_cache.overwrite_group_uid( - group_dict["id"], int(group_gid, 10) + group_dict["id"], int(group_gid[0], 10) ) # Read group attributes @@ -72,7 +72,7 @@ def groups(self) -> list[JSONDict]: attributes: JSONDict = {} attributes["cn"] = group_dict.get("name", None) attributes["description"] = group_dict.get("id", None) - attributes["gidNumber"] = group_dict["attributes"]["gid"] + attributes["gidNumber"] = group_dict["attributes"]["gid"][0] attributes["oauth_id"] = group_dict.get("id", None) # Add membership attributes members = self.query( @@ -107,9 +107,9 @@ def users(self) -> list[JSONDict]: # If user_uid exists then set the cache to the same value. # This ensures that any groups without a `gid` attribute will receive a # UID that does not overlap with existing groups - if user_uid := user_dict["attributes"]["uid"]: + if (user_uid := user_dict["attributes"]["uid"]) and len(user_dict["attributes"]["uid"]) == 1: self.uid_cache.overwrite_user_uid( - user_dict["id"], int(user_uid, 10) + user_dict["id"], int(user_uid[0], 10) ) # Read user attributes @@ -139,12 +139,12 @@ def users(self) -> list[JSONDict]: attributes["displayName"] = full_name attributes["mail"] = user_dict.get("email") attributes["description"] = "" - attributes["gidNumber"] = user_dict["attributes"]["uid"] + attributes["gidNumber"] = user_dict["attributes"]["uid"][0] attributes["givenName"] = first_name if first_name else "" attributes["homeDirectory"] = f"/home/{username}" if username else None attributes["oauth_id"] = user_dict.get("id", None) attributes["sn"] = last_name if last_name else "" - attributes["uidNumber"] = user_dict["attributes"]["uid"] + attributes["uidNumber"] = user_dict["attributes"]["uid"][0] output.append(attributes) except KeyError: pass diff --git a/run.py b/run.py index ae3dbf0..c228f20 100644 --- a/run.py +++ b/run.py @@ -17,7 +17,7 @@ parser.add_argument("-p", "--port", type=int, default=1389, help="Port to run on.") parser.add_argument("-s", "--client-secret", type=str, help="OAuth client secret.") parser.add_argument("--disable-mirrored-groups", action="store_false", - dest="enable_mirrored", default=True, + dest="enable_mirrored_groups", default=True, help="Disable creation of mirrored groups.") parser.add_argument("--debug", action="store_true", help="Enable debug logging.") # Options for Microsoft Entra backend