Merge branch 'devonh/token-allowed-emails' into quenting/guest-invite-link-design

This commit is contained in:
Devon Hudson committed 2026-11-13 21:19:48 +00:00
commit 04530732ef
4 files changed
+30 -2

No files matched your search

@@ -131,6 +131,9 @@ pub enum AllowedEmailsError {
#[serde(rename = "AddUserRegistrationTokenRequest")]
pub struct Request {
/// The token string. If not provided, a random token will be generated.
/// Anyone holding the token can open its invite URL, which shows the
/// username and email address it imposes, so a token provided here must be
/// as hard to guess as a generated one.
token: Option<String>,
/// Maximum number of times this token can be used. If not provided, the
+22
View File
@@ -1417,6 +1417,28 @@ mod tests {
assert!(upstream_sessions(&state, &response).is_none());
}
/// The fresh page a stale CSRF token sends the user back to keeps the
/// invite code the link carried
#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_post_invalid_csrf_keeps_token(pool: PgPool) {
setup();
let state = TestState::from_pool(pool).await.unwrap();
let cookies = CookieHelper::new();
let (csrf_token, _body) = render_page(&state, &cookies).await;
let request = cookies.with_cookies(Request::post("/register?token=invite").form(
serde_json::json!({
"csrf": format!("{csrf_token}invalid"),
"username": "alice",
"token": "invite",
}),
));
let response = state.request(request).await;
response.assert_status(StatusCode::SEE_OTHER);
response.assert_header_value(LOCATION, "/register?token=invite");
}
/// The continue URL of the tokens [`add_continue_token`] adds, which no
/// page of MAS and no redirect to one should show
const CONTINUE_URL: &str = "https://app.example.com/#/room/secretroom";
@@ -301,7 +301,10 @@ pub(super) async fn register(
// Check the rate limit if we are about to process the form. A
// passwordless code pinning or listing email addresses skips the
// registration limit, so that people behind one address can accept
// their invites together.
// their invites together. This can't register in bulk: such a code
// is minted by an admin client for the addresses it names, each
// address can register only one account, and the email
// authentication limits below still apply.
let skips_limit = registration_token.as_ref().is_some_and(|token| {
token.passwordless && (token.email.is_some() || token.allowed_emails.is_some())
});
+1 -1
View File
@@ -7571,7 +7571,7 @@
"type": "object",
"properties": {
"token": {
"description": "The token string. If not provided, a random token will be generated.",
"description": "The token string. If not provided, a random token will be generated.\nAnyone holding the token can open its invite URL, which shows the\nusername and email address it imposes, so a token provided here must be\nas hard to guess as a generated one.",
"type": [
"string",
"null"