From 580767f2dd2c15c6c01fc16e75cae6fb12fa5d34 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 2 Dec 2025 18:10:12 +0100 Subject: [PATCH] Simplify the consent screens --- templates/components/scope.html | 29 ++++++++-- templates/pages/consent.html | 66 +++++++++++++---------- templates/pages/device_consent.html | 79 +++++++++++++++------------ templates/pages/sso.html | 39 ++++++++------ translations/en.json | 83 ++++++++++++++--------------- 5 files changed, 173 insertions(+), 123 deletions(-) diff --git a/templates/components/scope.html b/templates/components/scope.html index 96b5119cb..6ad4affd9 100644 --- a/templates/components/scope.html +++ b/templates/components/scope.html @@ -6,9 +6,32 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. -#} +{# Macro to remove 'unsafe' scope from a scope list. Usage: + + {% call(scopes) scope.unsafe_scopes(scopes=["openid", "urn:synapse:admin:*"]) %} + {{ scopes }} + {% endcall %} +#} +{% macro unsafe_scopes(scopes) -%} + {% set ns = namespace(unsafe_scopes=[]) %} + {% set safe_scope_prefixes = ["openid", "urn:matrix:client:api:", "urn:matrix:org.matrix.msc2967.client:api:", "urn:matrix:client:device:", "urn:matrix:org.matrix.msc2967.client:device:"] %} + {% for scope in scopes %} + {% set ns.is_safe = False %} + {% for safe_scope_prefix in safe_scope_prefixes %} + {% if scope.startswith(safe_scope_prefix) %} + {% set ns.is_safe = True %} + {% endif %} + {% endfor %} + {% if not ns.is_safe %} + {% set ns.unsafe_scopes = ns.unsafe_scopes + [scope] %} + {% endif %} + {% endfor %} + {{ caller(ns.unsafe_scopes) }} +{%- endmacro %} + {% macro list(scopes) %}