1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-02 16:38:36 +00:00

add rate limiting for registration token validity

This commit is contained in:
Matthias Ahouansou 2024-07-11 13:14:10 +01:00
parent 499548321f
commit 613107e7cf
No known key found for this signature in database
2 changed files with 10 additions and 3 deletions

View file

@ -105,13 +105,13 @@ pub struct WellKnownConfig {
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "snake_case")]
pub enum Restriction {
Registration,
Login,
RegistrationTokenValidity,
#[default]
#[serde(rename = "")]
CatchAll,
}

View file

@ -7,7 +7,10 @@ use std::{
use dashmap::{mapref::entry::Entry, DashMap};
use ruma::{
api::{
client::{account::register, session::login},
client::{
account::{check_registration_token_validity, register},
session::login,
},
IncomingRequest, Metadata,
},
OwnedServerName, OwnedUserId,
@ -20,6 +23,10 @@ impl From<Metadata> for Restriction {
[
(register::v3::Request::METADATA, Restriction::Registration),
(login::v3::Request::METADATA, Restriction::Login),
(
check_registration_token_validity::v1::Request::METADATA,
Restriction::RegistrationTokenValidity,
),
]
.into_iter()
.find(|(other, _)| {