Limited use registration token support

Co-authored-by: Ginger <ginger@gingershaped.computer>
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
dasha_uwu
2026-01-24 11:29:56 +05:00
committed by Jason Volk
parent 0dbe79df8e
commit 56f3f5ea15
12 changed files with 494 additions and 43 deletions

View File

@@ -1,6 +1,6 @@
mod data;
use std::{collections::HashSet, ops::Range, sync::Arc};
use std::{ops::Range, sync::Arc};
use data::Data;
use ruma::{OwnedUserId, RoomAliasId, ServerName, UserId};
@@ -106,31 +106,6 @@ impl Service {
#[must_use]
pub fn is_read_only(&self) -> bool { self.db.db.is_read_only() }
pub fn get_registration_tokens(&self) -> HashSet<String> {
let mut tokens = HashSet::new();
if let Some(file) = &self
.server
.config
.registration_token_file
.as_ref()
{
match std::fs::read_to_string(file) {
| Err(e) => error!("Failed to read the registration token file: {e}"),
| Ok(text) => {
text.split_ascii_whitespace().for_each(|token| {
tokens.insert(token.to_owned());
});
},
}
}
if let Some(token) = &self.server.config.registration_token {
tokens.insert(token.to_owned());
}
tokens
}
pub fn init_rustls_provider(&self) -> Result {
if rustls::crypto::CryptoProvider::get_default().is_none() {
rustls::crypto::aws_lc_rs::default_provider()