This commit is contained in:
2025-09-23 23:11:25 +03:00
parent 48b47cfa88
commit e349c5e0f3

View File

@@ -21,6 +21,7 @@ def getenv(name):
# Import configuration # Import configuration
KANIDM_URL = getenv("KANIDM_URL") KANIDM_URL = getenv("KANIDM_URL")
KANIDM_TOKEN = read_file(getenv("KANIDM_TOKEN_PATH")).strip() KANIDM_TOKEN = read_file(getenv("KANIDM_TOKEN_PATH")).strip()
OWNER_USERNAME = getenv("OWNER_USERNAME")
# Fetch kanidm users list from userdata file # Fetch kanidm users list from userdata file
# Userdata file is json list with information about what users are configured by kanidm # Userdata file is json list with information about what users are configured by kanidm
@@ -73,6 +74,11 @@ for i in kanidm_users_raw:
i = i["attrs"] i = i["attrs"]
for uid in i["name"]: # [user].attrs.name is a list for uid in i["name"]: # [user].attrs.name is a list
if uid in users: # Don't apply anything for users who have no mastodon access (sp.mastodon.users) or didn't register if uid in users: # Don't apply anything for users who have no mastodon access (sp.mastodon.users) or didn't register
if uid == OWNER_USERNAME:
users[uid]["isKanidmUser"] = True
users[uid]["role"] = "Owner"
continue
for group in i["memberof"]: for group in i["memberof"]:
if group.startswith("sp.mastodon.admins@") or group.startswith("sp.admins@"): if group.startswith("sp.mastodon.admins@") or group.startswith("sp.admins@"):
if uid not in userdata: if uid not in userdata: