From 2d2cd1837e6b08b80dfc83f948407988fe24cabc Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Mon, 23 Nov 2026 20:36:59 +0100 Subject: [PATCH] Keep delegated staff and service tickets within assigned roles --- src/coulobre/hosting/panel_roles.py | 4 +--- src/coulobre/hosting/signon.py | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coulobre/hosting/panel_roles.py b/src/coulobre/hosting/panel_roles.py index aa811cc..04aaff8 100644 --- a/src/coulobre/hosting/panel_roles.py +++ b/src/coulobre/hosting/panel_roles.py @@ -31,9 +31,7 @@ def assigned_roles(user): if not user.is_authenticated or not user.is_active: return {} roles = {} - if user.is_superuser or ( - user.is_staff and user.has_perm("hosting.view_hostingaccount") - ): + if user.is_superuser: roles[PanelRole.ADMIN] = user.pk customer = getattr(user, "hosting_customer", None) if customer is not None: diff --git a/src/coulobre/hosting/signon.py b/src/coulobre/hosting/signon.py index e395411..27d473b 100644 --- a/src/coulobre/hosting/signon.py +++ b/src/coulobre/hosting/signon.py @@ -20,8 +20,9 @@ def issue_signon_grant(model, actor, **selection): now = timezone.now() model.objects.filter(expires_at__lte=now).delete() token = secrets.token_urlsafe(32) - role = getattr(actor, "panel_role", None) - scope = [role, assigned_roles(actor).get(role)] if role else [] + roles = assigned_roles(actor) + role = getattr(actor, "panel_role", None) or next(iter(roles), None) + scope = [role, roles.get(role)] if role else [] model.objects.create( token_digest=token_digest(token), actor=actor,