mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-29 11:57:32 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbc3808b8c |
No files matched your search
+11
-4
@@ -1,17 +1,26 @@
|
|||||||
|
#cargo-features = ["profile-rustflags"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["src/*", "xtask/*"]
|
members = ["src/*", "xtask/*"]
|
||||||
default-members = ["src/*"]
|
default-members = ["src/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
authors = ["Continuwuity Team and contributors <team@continuwuity.org>"]
|
authors = [
|
||||||
description = "A Matrix homeserver written in Rust, the official continuation of the conduwuit homeserver."
|
"June Clementine Strawberry <june@girlboss.ceo>",
|
||||||
|
"strawberry <strawberry@puppygock.gay>", # woof
|
||||||
|
"Jason Volk <jason@zemos.net>",
|
||||||
|
]
|
||||||
|
categories = ["network-programming"]
|
||||||
|
description = "a very cool Matrix chat homeserver written in Rust"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
homepage = "https://continuwuity.org/"
|
homepage = "https://continuwuity.org/"
|
||||||
|
keywords = ["chat", "matrix", "networking", "server", "uwu"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||||
|
rust-version = "1.86.0"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
@@ -839,8 +848,6 @@ unknown_lints = "allow"
|
|||||||
|
|
||||||
###################
|
###################
|
||||||
cargo = { level = "warn", priority = -1 }
|
cargo = { level = "warn", priority = -1 }
|
||||||
# Nobody except for us should be consuming these crates, they don't need metadata
|
|
||||||
cargo_common_metadata = { level = "allow"}
|
|
||||||
|
|
||||||
## some sadness
|
## some sadness
|
||||||
multiple_crate_versions = { level = "allow", priority = 1 }
|
multiple_crate_versions = { level = "allow", priority = 1 }
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Implemented toggling the ability for an account to log in without mutating any of its data. Contributed by @nex.
|
|
||||||
@@ -8,7 +8,7 @@ This document contains the help content for the `continuwuity` command-line prog
|
|||||||
|
|
||||||
## `continuwuity`
|
## `continuwuity`
|
||||||
|
|
||||||
A Matrix homeserver written in Rust, the official continuation of the conduwuit homeserver.
|
a very cool Matrix chat homeserver written in Rust
|
||||||
|
|
||||||
**Usage:** `continuwuity [OPTIONS]`
|
**Usage:** `continuwuity [OPTIONS]`
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Name: continuwuity
|
Name: continuwuity
|
||||||
Version: {{{ git_repo_version }}}
|
Version: {{{ git_repo_version }}}
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: A Matrix homeserver written in Rust.
|
Summary: Very cool Matrix chat homeserver written in Rust
|
||||||
|
|
||||||
License: Apache-2.0 AND MIT
|
License: Apache-2.0 AND MIT
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ Requires: glibc
|
|||||||
Requires: libstdc++
|
Requires: libstdc++
|
||||||
|
|
||||||
%global _description %{expand:
|
%global _description %{expand:
|
||||||
A Matrix homeserver written in Rust, the official continuation of the conduwuit homeserver.}
|
A cool hard fork of Conduit, a Matrix homeserver written in Rust}
|
||||||
|
|
||||||
%description %{_description}
|
%description %{_description}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_admin"
|
name = "conduwuit_admin"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub(super) async fn revoke_token(&self, token: String) -> Result {
|
|||||||
let Some(token) = self
|
let Some(token) = self
|
||||||
.services
|
.services
|
||||||
.registration_tokens
|
.registration_tokens
|
||||||
.validate_token(token)
|
.validate_token(&token)
|
||||||
.await
|
.await
|
||||||
else {
|
else {
|
||||||
return Err!("This token does not exist or has already expired.");
|
return Err!("This token does not exist or has already expired.");
|
||||||
|
|||||||
@@ -280,12 +280,7 @@ pub(super) async fn unsuspend(&self, user_id: String) -> Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
pub(super) async fn reset_password(
|
pub(super) async fn reset_password(&self, username: String, password: Option<String>) -> Result {
|
||||||
&self,
|
|
||||||
logout: bool,
|
|
||||||
username: String,
|
|
||||||
password: Option<String>,
|
|
||||||
) -> Result {
|
|
||||||
let user_id = parse_local_user_id(self.services, &username)?;
|
let user_id = parse_local_user_id(self.services, &username)?;
|
||||||
|
|
||||||
if user_id == self.services.globals.server_user {
|
if user_id == self.services.globals.server_user {
|
||||||
@@ -308,18 +303,7 @@ pub(super) async fn reset_password(
|
|||||||
write!(self, "Successfully reset the password for user {user_id}: `{new_password}`")
|
write!(self, "Successfully reset the password for user {user_id}: `{new_password}`")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.await?;
|
.await
|
||||||
|
|
||||||
if logout {
|
|
||||||
self.services
|
|
||||||
.users
|
|
||||||
.all_device_ids(&user_id)
|
|
||||||
.for_each(|device_id| self.services.users.remove_device(&user_id, device_id))
|
|
||||||
.await;
|
|
||||||
write!(self, "\nAll existing sessions have been logged out.").await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[admin_command]
|
||||||
@@ -1060,45 +1044,3 @@ pub(super) async fn logout(&self, user_id: String) -> Result {
|
|||||||
self.write_str(&format!("User {user_id} has been logged out from all devices."))
|
self.write_str(&format!("User {user_id} has been logged out from all devices."))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
|
||||||
pub(super) async fn disable_login(&self, user_id: String) -> Result {
|
|
||||||
self.bail_restricted()?;
|
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
|
||||||
assert!(
|
|
||||||
self.services.globals.user_is_local(&user_id),
|
|
||||||
"Parsed user_id must be a local user"
|
|
||||||
);
|
|
||||||
if user_id == self.services.globals.server_user {
|
|
||||||
return Err!("Not allowed to disable login for the server service account.",);
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.services.users.exists(&user_id).await {
|
|
||||||
return Err!("User {user_id} does not exist.");
|
|
||||||
}
|
|
||||||
if self.services.users.is_admin(&user_id).await {
|
|
||||||
return Err!("Admin users cannot have their login disallowed.");
|
|
||||||
}
|
|
||||||
self.services.users.disable_login(&user_id);
|
|
||||||
|
|
||||||
self.write_str(&format!(
|
|
||||||
"{user_id} can no longer log in. Their existing sessions remain unaffected."
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
#[admin_command]
|
|
||||||
pub(super) async fn enable_login(&self, user_id: String) -> Result {
|
|
||||||
self.bail_restricted()?;
|
|
||||||
let user_id = parse_local_user_id(self.services, &user_id)?;
|
|
||||||
assert!(
|
|
||||||
self.services.globals.user_is_local(&user_id),
|
|
||||||
"Parsed user_id must be a local user"
|
|
||||||
);
|
|
||||||
if !self.services.users.exists(&user_id).await {
|
|
||||||
return Err!("User {user_id} does not exist.");
|
|
||||||
}
|
|
||||||
self.services.users.enable_login(&user_id);
|
|
||||||
|
|
||||||
self.write_str(&format!("{user_id} can now log in.")).await
|
|
||||||
}
|
|
||||||
@@ -20,9 +20,6 @@ pub enum UserCommand {
|
|||||||
|
|
||||||
/// - Reset user password
|
/// - Reset user password
|
||||||
ResetPassword {
|
ResetPassword {
|
||||||
/// Log out existing sessions
|
|
||||||
#[arg(short, long)]
|
|
||||||
logout: bool,
|
|
||||||
/// Username of the user for whom the password should be reset
|
/// Username of the user for whom the password should be reset
|
||||||
username: String,
|
username: String,
|
||||||
/// New password for the user, if unspecified one is generated
|
/// New password for the user, if unspecified one is generated
|
||||||
@@ -116,22 +113,6 @@ pub enum UserCommand {
|
|||||||
user_id: String,
|
user_id: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// - Enable login for a user
|
|
||||||
EnableLogin {
|
|
||||||
/// Username of the user to enable login for
|
|
||||||
user_id: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// - Disable login for a user
|
|
||||||
///
|
|
||||||
/// Disables login for the specified user without deactivating or locking
|
|
||||||
/// their account. This prevents the user from obtaining new access tokens,
|
|
||||||
/// but does not invalidate existing sessions.
|
|
||||||
DisableLogin {
|
|
||||||
/// Username of the user to disable login for
|
|
||||||
user_id: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// - List local users in the database
|
/// - List local users in the database
|
||||||
#[clap(alias = "list")]
|
#[clap(alias = "list")]
|
||||||
ListUsers,
|
ListUsers,
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_api"
|
name = "conduwuit_api"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -880,7 +880,7 @@ pub(crate) async fn check_registration_token_validity(
|
|||||||
|
|
||||||
let valid = services
|
let valid = services
|
||||||
.registration_tokens
|
.registration_tokens
|
||||||
.validate_token(body.token.clone())
|
.validate_token(&body.token)
|
||||||
.await
|
.await
|
||||||
.is_some();
|
.is_some();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use axum_client_ip::InsecureClientIp;
|
|||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Error, Result, debug, err, info,
|
Err, Error, Result, debug, err, info,
|
||||||
utils::{self, ReadyExt, hash},
|
utils::{self, ReadyExt, hash},
|
||||||
warn,
|
|
||||||
};
|
};
|
||||||
use conduwuit_core::{debug_error, debug_warn};
|
use conduwuit_core::{debug_error, debug_warn};
|
||||||
use conduwuit_service::{Services, uiaa::SESSION_ID_LENGTH};
|
use conduwuit_service::{Services, uiaa::SESSION_ID_LENGTH};
|
||||||
@@ -13,7 +12,6 @@ use futures::StreamExt;
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId, UserId,
|
OwnedUserId, UserId,
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
|
||||||
session::{
|
session::{
|
||||||
get_login_token,
|
get_login_token,
|
||||||
get_login_types::{
|
get_login_types::{
|
||||||
@@ -186,15 +184,6 @@ pub(crate) async fn handle_login(
|
|||||||
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
|
return Err!(Request(Unknown("User ID does not belong to this homeserver")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services.users.is_locked(&user_id).await? {
|
|
||||||
return Err(Error::BadRequest(ErrorKind::UserLocked, "This account has been locked."));
|
|
||||||
}
|
|
||||||
|
|
||||||
if services.users.is_login_disabled(&user_id).await {
|
|
||||||
warn!(%user_id, "user attempted to log in with a login-disabled account");
|
|
||||||
return Err!(Request(Forbidden("This account is not permitted to log in.")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg!(feature = "ldap") && services.config.ldap.enable {
|
if cfg!(feature = "ldap") && services.config.ldap.enable {
|
||||||
match Box::pin(ldap_login(services, &user_id, &lowercased_user_id, password)).await {
|
match Box::pin(ldap_login(services, &user_id, &lowercased_user_id, password)).await {
|
||||||
| Ok(user_id) => Ok(user_id),
|
| Ok(user_id) => Ok(user_id),
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_build_metadata"
|
name = "conduwuit_build_metadata"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_core"
|
name = "conduwuit_core"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_database"
|
name = "conduwuit_database"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -394,10 +394,6 @@ pub(super) static MAPS: &[Descriptor] = &[
|
|||||||
name: "userid_lock",
|
name: "userid_lock",
|
||||||
..descriptor::RANDOM_SMALL
|
..descriptor::RANDOM_SMALL
|
||||||
},
|
},
|
||||||
Descriptor {
|
|
||||||
name: "userid_logindisabled",
|
|
||||||
..descriptor::RANDOM_SMALL
|
|
||||||
},
|
|
||||||
Descriptor {
|
Descriptor {
|
||||||
name: "userid_presenceid",
|
name: "userid_presenceid",
|
||||||
..descriptor::RANDOM_SMALL
|
..descriptor::RANDOM_SMALL
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_macros"
|
name = "conduwuit_macros"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
+6
-2
@@ -2,12 +2,15 @@
|
|||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
default-run = "conduwuit"
|
default-run = "conduwuit"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
metadata.crane.workspace = true
|
metadata.crane.workspace = true
|
||||||
|
|
||||||
@@ -20,13 +23,14 @@ crate-type = [
|
|||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
name = "continuwuity"
|
name = "continuwuity"
|
||||||
maintainer = "Continuwuity Team and contributors <team@continuwuity.org>"
|
maintainer = "continuwuity developers <contact@continuwuity.org>"
|
||||||
|
copyright = "2024, continuwuity developers"
|
||||||
license-file = ["../../LICENSE", "3"]
|
license-file = ["../../LICENSE", "3"]
|
||||||
depends = "$auto, ca-certificates"
|
depends = "$auto, ca-certificates"
|
||||||
breaks = ["conduwuit (<<0.5.0)"]
|
breaks = ["conduwuit (<<0.5.0)"]
|
||||||
replaces = ["conduwuit (<<0.5.0)"]
|
replaces = ["conduwuit (<<0.5.0)"]
|
||||||
extended-description = """\
|
extended-description = """\
|
||||||
A Matrix homeserver written in Rust, the official continuation of the conduwuit homeserver."""
|
a cool hard fork of Conduit, a Matrix homeserver written in Rust"""
|
||||||
section = "net"
|
section = "net"
|
||||||
priority = "optional"
|
priority = "optional"
|
||||||
conf-files = ["/etc/conduwuit/conduwuit.toml"]
|
conf-files = ["/etc/conduwuit/conduwuit.toml"]
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_router"
|
name = "conduwuit_router"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_service"
|
name = "conduwuit_service"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ struct Services {
|
|||||||
|
|
||||||
/// A validated registration token which may be used to create an account.
|
/// A validated registration token which may be used to create an account.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ValidToken {
|
pub struct ValidToken<'token> {
|
||||||
pub token: String,
|
pub token: &'token str,
|
||||||
pub source: ValidTokenSource,
|
pub source: ValidTokenSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for ValidToken {
|
impl std::fmt::Display for ValidToken<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "`{}` --- {}", self.token, &self.source)
|
write!(f, "`{}` --- {}", self.token, &self.source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq<str> for ValidToken {
|
impl PartialEq<str> for ValidToken<'_> {
|
||||||
fn eq(&self, other: &str) -> bool { self.token == other }
|
fn eq(&self, other: &str) -> bool { self.token == other }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,11 +85,11 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the registration token set in the config file, if it exists.
|
/// Get the registration token set in the config file, if it exists.
|
||||||
pub fn get_config_file_token(&self) -> Option<ValidToken> {
|
pub fn get_config_file_token(&self) -> Option<ValidToken<'_>> {
|
||||||
self.services
|
self.services
|
||||||
.config
|
.config
|
||||||
.registration_token
|
.registration_token
|
||||||
.clone()
|
.as_deref()
|
||||||
.map(|token| ValidToken {
|
.map(|token| ValidToken {
|
||||||
token,
|
token,
|
||||||
source: ValidTokenSource::ConfigFile,
|
source: ValidTokenSource::ConfigFile,
|
||||||
@@ -97,7 +97,7 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Validate a registration token.
|
/// Validate a registration token.
|
||||||
pub async fn validate_token(&self, token: String) -> Option<ValidToken> {
|
pub async fn validate_token<'token>(&self, token: &'token str) -> Option<ValidToken<'token>> {
|
||||||
// Check the registration token in the config first
|
// Check the registration token in the config first
|
||||||
if self
|
if self
|
||||||
.get_config_file_token()
|
.get_config_file_token()
|
||||||
@@ -110,7 +110,7 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now check the database
|
// Now check the database
|
||||||
if let Some(token_info) = self.db.lookup_token_info(&token).await
|
if let Some(token_info) = self.db.lookup_token_info(token).await
|
||||||
&& token_info.is_valid()
|
&& token_info.is_valid()
|
||||||
{
|
{
|
||||||
return Some(ValidToken {
|
return Some(ValidToken {
|
||||||
@@ -124,7 +124,7 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Mark a valid token as having been used to create a new account.
|
/// Mark a valid token as having been used to create a new account.
|
||||||
pub fn mark_token_as_used(&self, ValidToken { token, source }: ValidToken) {
|
pub fn mark_token_as_used(&self, ValidToken { token, source }: ValidToken<'_>) {
|
||||||
match source {
|
match source {
|
||||||
| ValidTokenSource::ConfigFile => {
|
| ValidTokenSource::ConfigFile => {
|
||||||
// we don't track uses of the config file token, do nothing
|
// we don't track uses of the config file token, do nothing
|
||||||
@@ -132,7 +132,7 @@ impl Service {
|
|||||||
| ValidTokenSource::Database(mut info) => {
|
| ValidTokenSource::Database(mut info) => {
|
||||||
info.uses = info.uses.saturating_add(1);
|
info.uses = info.uses.saturating_add(1);
|
||||||
|
|
||||||
self.db.save_token(&token, &info);
|
self.db.save_token(token, &info);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ impl Service {
|
|||||||
///
|
///
|
||||||
/// Note that some tokens (like the one set in the config file) cannot be
|
/// Note that some tokens (like the one set in the config file) cannot be
|
||||||
/// revoked.
|
/// revoked.
|
||||||
pub fn revoke_token(&self, ValidToken { token, source }: ValidToken) -> Result {
|
pub fn revoke_token(&self, ValidToken { token, source }: ValidToken<'_>) -> Result {
|
||||||
match source {
|
match source {
|
||||||
| ValidTokenSource::ConfigFile => {
|
| ValidTokenSource::ConfigFile => {
|
||||||
// the config file token cannot be revoked
|
// the config file token cannot be revoked
|
||||||
@@ -151,19 +151,19 @@ impl Service {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
| ValidTokenSource::Database(_) => {
|
| ValidTokenSource::Database(_) => {
|
||||||
self.db.revoke_token(&token);
|
self.db.revoke_token(token);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all valid registration tokens.
|
/// Iterate over all valid registration tokens.
|
||||||
pub fn iterate_tokens(&self) -> impl Stream<Item = ValidToken> + Send + '_ {
|
pub fn iterate_tokens(&self) -> impl Stream<Item = ValidToken<'_>> + Send + '_ {
|
||||||
let db_tokens = self
|
let db_tokens = self
|
||||||
.db
|
.db
|
||||||
.iterate_and_clean_tokens()
|
.iterate_and_clean_tokens()
|
||||||
.map(|(token, info)| ValidToken {
|
.map(|(token, info)| ValidToken {
|
||||||
token: token.to_owned(),
|
token,
|
||||||
source: ValidTokenSource::Database(info),
|
source: ValidTokenSource::Database(info),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ pub async fn try_auth(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
| AuthData::RegistrationToken(t) => {
|
| AuthData::RegistrationToken(t) => {
|
||||||
let token = t.token.trim().to_owned();
|
let token = t.token.trim();
|
||||||
|
|
||||||
if let Some(valid_token) = self
|
if let Some(valid_token) = self
|
||||||
.services
|
.services
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ struct Data {
|
|||||||
userid_password: Arc<Map>,
|
userid_password: Arc<Map>,
|
||||||
userid_suspension: Arc<Map>,
|
userid_suspension: Arc<Map>,
|
||||||
userid_lock: Arc<Map>,
|
userid_lock: Arc<Map>,
|
||||||
userid_logindisabled: Arc<Map>,
|
|
||||||
userid_selfsigningkeyid: Arc<Map>,
|
userid_selfsigningkeyid: Arc<Map>,
|
||||||
userid_usersigningkeyid: Arc<Map>,
|
userid_usersigningkeyid: Arc<Map>,
|
||||||
useridprofilekey_value: Arc<Map>,
|
useridprofilekey_value: Arc<Map>,
|
||||||
@@ -118,7 +117,6 @@ impl crate::Service for Service {
|
|||||||
userid_password: args.db["userid_password"].clone(),
|
userid_password: args.db["userid_password"].clone(),
|
||||||
userid_suspension: args.db["userid_suspension"].clone(),
|
userid_suspension: args.db["userid_suspension"].clone(),
|
||||||
userid_lock: args.db["userid_lock"].clone(),
|
userid_lock: args.db["userid_lock"].clone(),
|
||||||
userid_logindisabled: args.db["userid_logindisabled"].clone(),
|
|
||||||
userid_selfsigningkeyid: args.db["userid_selfsigningkeyid"].clone(),
|
userid_selfsigningkeyid: args.db["userid_selfsigningkeyid"].clone(),
|
||||||
userid_usersigningkeyid: args.db["userid_usersigningkeyid"].clone(),
|
userid_usersigningkeyid: args.db["userid_usersigningkeyid"].clone(),
|
||||||
useridprofilekey_value: args.db["useridprofilekey_value"].clone(),
|
useridprofilekey_value: args.db["useridprofilekey_value"].clone(),
|
||||||
@@ -297,16 +295,6 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disable_login(&self, user_id: &UserId) {
|
|
||||||
self.db.userid_logindisabled.insert(user_id, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn enable_login(&self, user_id: &UserId) { self.db.userid_logindisabled.remove(user_id); }
|
|
||||||
|
|
||||||
pub async fn is_login_disabled(&self, user_id: &UserId) -> bool {
|
|
||||||
self.db.userid_logindisabled.contains(user_id).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if account is active, infallible
|
/// Check if account is active, infallible
|
||||||
pub async fn is_active(&self, user_id: &UserId) -> bool {
|
pub async fn is_active(&self, user_id: &UserId) -> bool {
|
||||||
!self.is_deactivated(user_id).await.unwrap_or(true)
|
!self.is_deactivated(user_id).await.unwrap_or(true)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "conduwuit_web"
|
name = "conduwuit_web"
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "xtask-generate-commands"
|
name = "xtask-generate-commands"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "xtask"
|
name = "xtask"
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
categories.workspace = true
|
||||||
description.workspace = true
|
description.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
|
keywords.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
readme.workspace = true
|
readme.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in new issue
Block a user