Integrate MAS with Synapse

This commit is contained in:
Your Name
2025-12-01 08:14:13 -06:00
parent df07d51d8b
commit a3d39d901b
404 changed files with 22542 additions and 2 deletions

View File

@@ -0,0 +1,66 @@
{#
Copyright 2024, 2025 New Vector Ltd.
Copyright 2021-2024 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% from "components/idp_brand.html" import logo %}
{% block content %}
<form method="GET" class="flex flex-col gap-10" action="{{ '/register/password' | prefix_url }}">
<header class="page-heading">
<div class="icon">
{{ icon.user_profile_solid() }}
</div>
<div class="header">
<h1 class="title">{{ _("mas.register.create_account.heading") }}</h1>
{% if features.password_registration %}
<p class="text">{{ _("mas.register.create_account.description") }}</p>
{% endif %}
</div>
</header>
{% if features.password_registration %}
{% call(f) field.field(label=_("common.username"), name="username", form_state=form) %}
<input {{ field.attributes(f) }} class="cpd-text-control" type="text" autocomplete="username" autocorrect="off" autocapitalize="off" data-choose-username />
<div class="cpd-form-message cpd-form-help-message" id="{{ f.id }}-help">
@username:{{ branding.server_name }}
</div>
{% endcall %}
{% endif %}
<div class="cpd-form-root">
{% for key, value in next["params"] | default({}) | items %}
<input type="hidden" name="{{ key }}" value="{{ value }}" />
{% endfor %}
{% if features.password_registration %}
{% if features.password_registration_email_required %}
{{ button.button(text=_("mas.register.continue_with_email")) }}
{% else %}
{{ button.button(text=_("mas.register.continue_with_password")) }}
{% endif %}
{% endif %}
{% if providers %}
{% set params = next["params"] | default({}) | to_params(prefix="?") %}
{% for provider in providers %}
{% set name = provider.human_name or (provider.issuer | simplify_url(keep_path=True)) or provider.id %}
<a class="cpd-button {%- if provider.brand_name %} has-icon {%- endif %}" data-kind="secondary" data-size="lg" href="{{ ('/upstream/authorize/' ~ provider.id ~ params) | prefix_url }}">
{{ logo(provider.brand_name) }}
{{ _("mas.login.continue_with_provider", provider=name) }}
</a>
{% endfor %}
{% endif %}
{% set params = next["params"] | default({}) | to_params(prefix="?") %}
{{ button.link_tertiary(text=_("mas.register.call_to_login"), href="/login" ~ params) }}
</div>
</form>
{% endblock content %}

View File

@@ -0,0 +1,82 @@
{#
Copyright 2024, 2025 New Vector Ltd.
Copyright 2021-2024 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% block content %}
<header class="page-heading">
<div class="icon">
{{ icon.user_profile_solid() }}
</div>
<div class="header">
<h1 class="title">{{ _("mas.register.create_account.heading") }}</h1>
</div>
</header>
<form method="POST" class="cpd-form-root">
{% for error in form.errors %}
{# Special case for the captcha error, as we want to put it at the bottom #}
{% if error.kind != "captcha" %}
<div class="text-critical font-medium">
{{ errors.form_error_message(error=error) }}
</div>
{% endif %}
{% endfor %}
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
{% call(f) field.field(label=_("common.username"), name="username", form_state=form) %}
<input {{ field.attributes(f) }} class="cpd-text-control" type="text" autocomplete="username" autocorrect="off" autocapitalize="none" required data-choose-username />
{{ field.error(error={"kind": "policy", "code": "username-invalid-chars"}, hidden=true) }}
{% endcall %}
{% if features.password_registration_email_required %}
{% call(f) field.field(label=_("common.email_address"), name="email", form_state=form) %}
<input {{ field.attributes(f) }} class="cpd-text-control" type="email" autocomplete="email" required />
{% endcall %}
{% endif %}
{% call(f) field.field(label=_("common.password"), name="password", form_state=form) %}
<input {{ field.attributes(f) }} class="cpd-text-control" type="password" autocomplete="new-password" required />
{% endcall %}
{% call(f) field.field(label=_("common.password_confirm"), name="password_confirm", form_state=form) %}
<input {{ field.attributes(f) }} class="cpd-text-control" type="password" autocomplete="new-password" required />
{% endcall %}
{% if branding.tos_uri is not none %}
{% call(f) field.field(label=_("mas.register.terms_of_service", tos_uri=branding.tos_uri), name="accept_terms", form_state=form, inline=true, class="my-4") %}
<div class="cpd-form-inline-field-control">
<div class="cpd-checkbox-container">
<input {{ field.attributes(f) }} class="cpd-checkbox-input" type="checkbox" required />
<div class="cpd-checkbox-ui">
{{ icon.check() }}
</div>
</div>
</div>
{% endcall %}
{% endif %}
{{ captcha.form(class="mb-4 self-center") }}
{% for error in form.errors %}
{# Special case for the captcha error #}
{% if error.kind == "captcha" %}
<div class="text-critical font-medium text-center -mt-4 mb-4">
{{ errors.form_error_message(error=error) }}
</div>
{% endif %}
{% endfor %}
{{ button.button(text=_("action.continue")) }}
{% set params = next["params"] | default({}) | to_params(prefix="?") %}
{{ button.link_tertiary(text=_("mas.register.call_to_login"), href="/login" ~ params) }}
</form>
{% endblock content %}

View File

@@ -0,0 +1,52 @@
{#
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% block content %}
<header class="page-heading">
<div class="icon">
{{ icon.visibility_on() }}
</div>
<div class="header">
<h1 class="title">{{ _("mas.choose_display_name.headline") }}</h1>
<p class="text">{{ _("mas.choose_display_name.description") }}</p>
</div>
</header>
<div class="cpd-form-root">
<form method="POST" class="cpd-form-root">
{% if form.errors is not empty %}
{% for error in form.errors %}
<div class="text-critical font-medium">
{{ errors.form_error_message(error=error) }}
</div>
{% endfor %}
{% endif %}
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
<input type="hidden" name="action" value="set" />
{% call(f) field.field(label=_("common.display_name"), name="display_name", form_state=form, class="mb-4") %}
<input {{ field.attributes(f) }}
id="cpd-text-control"
type="text"
maxlength="256"
class="cpd-text-control"
required />
{% endcall %}
{{ button.button(text=_("action.continue")) }}
</form>
<form method="POST" class="cpd-form-root">
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
<input type="hidden" name="action" value="skip" />
{{ button.button(text=_("action.skip"), kind="tertiary") }}
</form>
</div>
{% endblock content %}

View File

@@ -0,0 +1,30 @@
{#
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% block content %}
<main class="flex flex-col gap-6">
<header class="page-heading">
<div class="icon invalid">
{{ icon.error_solid() }}
</div>
<div class="header">
<h1 class="title">
{{ _("mas.email_in_use.title", email=email) }}
</h1>
<p class="text">
{{ _("mas.email_in_use.description") }}
</p>
</div>
</header>
{% set params = action | default({}) | to_params(prefix="?") %}
{{ button.link_outline(text=_("action.start_over"), href="/register" ~ params) }}
</main>
{% endblock %}

View File

@@ -0,0 +1,44 @@
{#
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% block content %}
<header class="page-heading">
<div class="icon">
{{ icon.key_solid() }}
</div>
<div class="header">
<h1 class="title">{{ _("mas.registration_token.headline") }}</h1>
<p class="text">{{ _("mas.registration_token.description") }}</p>
</div>
</header>
<div class="cpd-form-root">
<form method="POST" class="cpd-form-root">
{% if form.errors is not empty %}
{% for error in form.errors %}
<div class="text-critical font-medium">
{{ errors.form_error_message(error=error) }}
</div>
{% endfor %}
{% endif %}
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
{% call(f) field.field(label=_("mas.registration_token.field"), name="token", form_state=form, class="mb-4") %}
<input {{ field.attributes(f) }}
id="cpd-text-control"
type="text"
class="cpd-text-control"
required />
{% endcall %}
{{ button.button(text=_("action.continue")) }}
</form>
</div>
{% endblock content %}

View File

@@ -0,0 +1,53 @@
{#
Copyright 2024, 2025 New Vector Ltd.
Copyright 2022-2024 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}
{% extends "base.html" %}
{% block content %}
<header class="page-heading">
<div class="icon">
{{ icon.send_solid() }}
</div>
<div class="header">
<h1 class="title">{{ _("mas.verify_email.headline") }}</h1>
<p class="text">{{ _("mas.verify_email.description", email=authentication.email) }}</p>
</div>
</header>
<form method="POST" class="cpd-form-root">
{% if form.errors is not empty %}
{% for error in form.errors %}
<div class="text-critical font-medium">
{{ errors.form_error_message(error=error) }}
</div>
{% endfor %}
{% endif %}
<input type="hidden" name="csrf" value="{{ csrf_token }}" />
{% call(f) field.field(label=_("mas.verify_email.6_digit_code"), name="code", form_state=form, class="mb-4 self-center") %}
<div class="cpd-mfa-container">
<input {{ field.attributes(f) }}
inputmode="numeric"
type="text"
minlength="0"
maxlength="6"
class="cpd-mfa-control"
pattern="\d{6}"
required
autocomplete="one-time-code">
{% for _ in range(6) %}
<div class="cpd-mfa-digit" aria-hidden="true"></div>
{% endfor %}
</div>
{% endcall %}
{{ button.button(text=_("action.continue")) }}
</form>
{% endblock content %}