Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Update the SSO username picker template to comply with SIWA guidelines #12210

Merged
merged 7 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12210.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the SSO username picker template to comply with SIWA guidelines.
6 changes: 4 additions & 2 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ Below are the templates Synapse will look for when generating pages related to S
for the brand of the IdP
* `user_attributes`: an object containing details about the user that
we received from the IdP. May have the following attributes:
* display_name: the user's display_name
* emails: a list of email addresses
* `display_name`: the user's display name
* `emails`: a list of email addresses
* `remote_user_id`: the user's ID on the IdP, [converted](https://spec.matrix.org/v1.2/appendices/#mapping-from-other-character-sets)
to the valid syntax for a Matrix username
The template should render a form which submits the following fields:
* `username`: the localpart of the user's chosen user id
* `sso_new_user_consent.html`: HTML page allowing the user to consent to the
Expand Down
6 changes: 3 additions & 3 deletions synapse/res/templates/sso_auth_account_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@
</head>
<body>
<header>
<h1>Your account is nearly ready</h1>
<p>Check your details before creating an account on {{ server_name }}</p>
<h1>Choose your user name</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@babolivier Per the issue this should be:

Choose your account name

<p>This is required to create your account on {{ server_name }}, and you can't change this later.</p>
</header>
<main>
<form method="post" class="form__input" id="form">
<div class="username_input" id="username_input">
<label for="field-username">Username</label>
<div class="prefix">@</div>
<input type="text" name="username" id="field-username" autofocus>
<input type="text" name="username" id="field-username" value="{{ user_attributes.remote_user_id }}" autofocus>
<div class="postfix">:{{ server_name }}</div>
</div>
<output for="username_input" id="field-username-output"></output>
Expand Down
5 changes: 4 additions & 1 deletion synapse/rest/synapse/client/pick_username.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from synapse.http.servlet import parse_boolean, parse_string
from synapse.http.site import SynapseRequest
from synapse.types import JsonDict
from synapse.types import JsonDict, map_username_to_mxid_localpart
from synapse.util.templates import build_jinja_env

if TYPE_CHECKING:
Expand Down Expand Up @@ -98,6 +98,9 @@ async def _async_render_GET(self, request: Request) -> None:
"user_attributes": {
"display_name": session.display_name,
"emails": session.emails,
"remote_user_id": map_username_to_mxid_localpart(
session.remote_user_id
),
},
}

Expand Down