Compare commits
21 Commits
b9d5c25137
...
develop
Author | SHA1 | Date | |
---|---|---|---|
b2da9b5dc5 | |||
ff578ab849
|
|||
0cffafcd77 | |||
e88ad47af9 | |||
bf6c3d5cb0
|
|||
2f101bedc3 | |||
30b118a621 | |||
cf359b4950
|
|||
c101fba07c | |||
01778866e0 | |||
2bfa5161ee | |||
ae57282dda | |||
0e022fabef | |||
b0623a3f1b | |||
56afe2688d | |||
66179ba858 | |||
63f82eab07
|
|||
f00adf9276
|
|||
216b4cee80
|
|||
cdc02a601d
|
|||
8bcb479b57
|
29
Cargo.toml
29
Cargo.toml
@@ -13,7 +13,7 @@ config = "./spellcheck.toml"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
# Errors
|
# Errors
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
thiserror = "1.0.50"
|
thiserror = "2.0.0"
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-std = "1.12.0"
|
async-std = "1.12.0"
|
||||||
@@ -26,12 +26,12 @@ tokio-stream = "0.1.15"
|
|||||||
# Utils
|
# Utils
|
||||||
base64 = "0.22.0"
|
base64 = "0.22.0"
|
||||||
const_format = "0.2.32"
|
const_format = "0.2.32"
|
||||||
rand = "0.8.5"
|
rand = "0.9.1"
|
||||||
validator = { version = "0.17.0", features = ["derive"] }
|
validator = { version = "0.17.0", features = ["derive"] }
|
||||||
# Http client
|
# Http client
|
||||||
reqwest = "0.11.24"
|
reqwest = "0.12.0"
|
||||||
# Password strength estimation
|
# Password strength estimation
|
||||||
zxcvbn = "2.2.2"
|
zxcvbn = { version = "3.0.0", features = ["ser"] }
|
||||||
# Image processing/conversion
|
# Image processing/conversion
|
||||||
image = "0.25.1"
|
image = "0.25.1"
|
||||||
# Get the application version
|
# Get the application version
|
||||||
@@ -44,13 +44,16 @@ tracing = "0.1.40"
|
|||||||
tracing-forest = "0.1.6"
|
tracing-forest = "0.1.6"
|
||||||
|
|
||||||
# SCSS -> CSS + usage in rust code
|
# SCSS -> CSS + usage in rust code
|
||||||
turf = "0.9.3"
|
turf = "0.10.0"
|
||||||
|
|
||||||
# Dioxus
|
# Dioxus
|
||||||
dioxus-free-icons = { version = "0.9", features = ["ionicons", "font-awesome-solid"] }
|
dioxus-free-icons = { version = "0.9", features = ["ionicons", "font-awesome-solid"] }
|
||||||
modx = "0.1.4"
|
modx = "0.1.4"
|
||||||
|
|
||||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
|
# Utils
|
||||||
|
getrandom = { version = "0.3.2", features = ["wasm_js"] }
|
||||||
|
|
||||||
# Logging/tracing
|
# Logging/tracing
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
tracing-web = "0.1.3"
|
tracing-web = "0.1.3"
|
||||||
@@ -65,6 +68,7 @@ matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev =
|
|||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
# Utils
|
# Utils
|
||||||
time = "0.3.36"
|
time = "0.3.36"
|
||||||
|
getrandom = { version = "0.3.2" }
|
||||||
|
|
||||||
# Logging/tracing
|
# Logging/tracing
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
||||||
@@ -75,9 +79,24 @@ dioxus = { version = "0.6.3", features = ["desktop"] }
|
|||||||
# Matrix
|
# Matrix
|
||||||
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev = "fa6066b8", default-features = false, features = ["rustls-tls"] }
|
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev = "fa6066b8", default-features = false, features = ["rustls-tls"] }
|
||||||
|
|
||||||
|
[target.wasm32-unknown-unknown]
|
||||||
|
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
regex = "1.10.3"
|
regex = "1.10.3"
|
||||||
|
|
||||||
|
[profile]
|
||||||
|
|
||||||
|
[profile.wasm-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
[profile.server-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
|
||||||
|
[profile.android-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
|
||||||
[package.metadata.turf]
|
[package.metadata.turf]
|
||||||
minify = true
|
minify = true
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@ RUN apt update \
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Workaround waiting for the dioxus 0.7 release (cf. https://github.com/DioxusLabs/dioxus/issues/4238)
|
||||||
|
ENV RUSTFLAGS="--cfg getrandom_backend=\"wasm_js\""
|
||||||
RUN dx build -r --platform web -- -j ${JOBS_NB}
|
RUN dx build -r --platform web -- -j ${JOBS_NB}
|
||||||
|
|
||||||
|
|
||||||
|
8
build.rs
8
build.rs
@@ -124,7 +124,7 @@ fn export_variables(tasks: Vec<Task>) {
|
|||||||
"#[allow(dead_code)]\nmod {} {{\n",
|
"#[allow(dead_code)]\nmod {} {{\n",
|
||||||
task.module_name
|
task.module_name
|
||||||
)) {
|
)) {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,14 +143,14 @@ fn export_variables(tasks: Vec<Task>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for variable in variables {
|
for variable in variables {
|
||||||
if let Err(err) = dst_file.write_fmt(format_args!(" pub {}\n", variable)) {
|
if let Err(err) = dst_file.write_fmt(format_args!(" pub {variable}\n")) {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = dst_file.write(b"}\n") {
|
if let Err(err) = dst_file.write(b"}\n") {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
FROM rust:1.86 AS builder
|
FROM rust:1.88 AS builder
|
||||||
|
|
||||||
RUN apt update \
|
RUN apt update \
|
||||||
&& apt install -y --no-install-recommends libclang-dev hunspell \
|
&& apt install -y --no-install-recommends libclang-dev hunspell \
|
||||||
|
@@ -3,7 +3,7 @@ use std::future::Future;
|
|||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::{collections::HashMap, future::IntoFuture};
|
use std::{collections::HashMap, future::IntoFuture};
|
||||||
|
|
||||||
use rand::distributions::{Alphanumeric, DistString};
|
use rand::distr::{Alphanumeric, SampleString};
|
||||||
use reqwest::Result as RequestResult;
|
use reqwest::Result as RequestResult;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ async fn fetch_dicebear_svg(
|
|||||||
// TODO: Use configuration file
|
// TODO: Use configuration file
|
||||||
let url = "dicebear.tools.adrien.run";
|
let url = "dicebear.tools.adrien.run";
|
||||||
|
|
||||||
let seed = Alphanumeric.sample_string(&mut rand::thread_rng(), 16);
|
let seed = Alphanumeric.sample_string(&mut rand::rng(), 16);
|
||||||
let type_str = r#type.to_string();
|
let type_str = r#type.to_string();
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://{url}/8.x/{type_str}/svg?seed={seed}&randomizeIds=true{}{}",
|
"https://{url}/8.x/{type_str}/svg?seed={seed}&randomizeIds=true{}{}",
|
||||||
|
@@ -4,7 +4,7 @@ use const_format::formatcp;
|
|||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
||||||
use zxcvbn::zxcvbn;
|
use zxcvbn::{zxcvbn, Score};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
domain::model::session::Session,
|
domain::model::session::Session,
|
||||||
@@ -348,14 +348,14 @@ fn validate_id(id: &Option<String>, process: &Process) -> Result<(), ValidationE
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct PasswordValidationResult {
|
struct PasswordValidationResult {
|
||||||
score: u8,
|
score: Score,
|
||||||
rating: f64, // 0 <= rating <= 1
|
rating: f64, // 0 <= rating <= 1
|
||||||
suggestions: Vec<String>,
|
suggestions: Vec<String>,
|
||||||
}
|
}
|
||||||
impl PasswordValidationResult {
|
impl PasswordValidationResult {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
PasswordValidationResult {
|
PasswordValidationResult {
|
||||||
score: 0,
|
score: Score::Zero,
|
||||||
rating: 0.0,
|
rating: 0.0,
|
||||||
suggestions: Vec::<String>::new(),
|
suggestions: Vec::<String>::new(),
|
||||||
}
|
}
|
||||||
@@ -366,9 +366,7 @@ fn compute_password_score(
|
|||||||
password: &str,
|
password: &str,
|
||||||
with_suggestions: Option<bool>,
|
with_suggestions: Option<bool>,
|
||||||
) -> Option<PasswordValidationResult> {
|
) -> Option<PasswordValidationResult> {
|
||||||
let Ok(estimate) = zxcvbn(password, &[]) else {
|
let estimate = zxcvbn(password, &[]);
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut result = PasswordValidationResult::new();
|
let mut result = PasswordValidationResult::new();
|
||||||
result.score = estimate.score();
|
result.score = estimate.score();
|
||||||
@@ -396,7 +394,7 @@ fn validate_password(password: &Option<String>, process: &Process) -> Result<(),
|
|||||||
if let Some(password) = password {
|
if let Some(password) = password {
|
||||||
if let Some(result) = compute_password_score(password, Some(true)) {
|
if let Some(result) = compute_password_score(password, Some(true)) {
|
||||||
// TODO: To configuration?
|
// TODO: To configuration?
|
||||||
if result.score <= 2 {
|
if [Score::Zero, Score::One, Score::Two].contains(&result.score) {
|
||||||
let mut err = ValidationError::new(TOO_WEAK_PASSWORD_ERROR_NAME);
|
let mut err = ValidationError::new(TOO_WEAK_PASSWORD_ERROR_NAME);
|
||||||
err.add_param(Cow::from("score"), &result.score);
|
err.add_param(Cow::from("score"), &result.score);
|
||||||
err.add_param(Cow::from("rating"), &result.rating);
|
err.add_param(Cow::from("rating"), &result.rating);
|
||||||
|
Reference in New Issue
Block a user