Compare commits
1 Commits
058dc383f8
...
7d9d0b4d2e
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d9d0b4d2e |
1979
moneymgr_backend/Cargo.lock
generated
1979
moneymgr_backend/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,35 +4,36 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.11.9"
|
||||
env_logger = "0.11.8"
|
||||
log = "0.4.29"
|
||||
diesel = { version = "2.3.6", features = ["postgres", "r2d2"] }
|
||||
diesel = { version = "2.2.12", features = ["postgres", "r2d2"] }
|
||||
diesel_migrations = "2.2.0"
|
||||
clap = { version = "4.5.59", features = ["env", "derive"] }
|
||||
actix-web = "4.13.0"
|
||||
actix-web = "4.11.0"
|
||||
actix-cors = "0.7.1"
|
||||
actix-multipart = "0.7.2"
|
||||
actix-remote-ip = "0.1.0"
|
||||
actix-session = { version = "0.11.0", features = ["redis-session"] }
|
||||
actix-session = { version = "0.10.1", features = ["redis-session"] }
|
||||
actix-files = "0.6.10"
|
||||
lazy_static = "1.5.0"
|
||||
anyhow = "1.0.101"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
rust-s3 = "0.37.1"
|
||||
rust-s3 = "0.36.0-beta.2"
|
||||
thiserror = "2.0.18"
|
||||
tokio = "1.49.0"
|
||||
futures-util = "0.3.32"
|
||||
tokio = "1.45.1"
|
||||
futures-util = "0.3.31"
|
||||
serde_json = "1.0.149"
|
||||
light-openid = "1.1.0"
|
||||
rand = "0.10.0"
|
||||
light-openid = "1.0.4"
|
||||
rand = "0.9.2"
|
||||
ipnet = { version = "2.11.0", features = ["serde"] }
|
||||
lazy-regex = "3.6.0"
|
||||
lazy-regex = "3.4.2"
|
||||
jwt-simple = { version = "0.12.14", default-features = false, features = ["pure-rust"] }
|
||||
mime_guess = "2.0.5"
|
||||
rust-embed = { version = "8.11.0" }
|
||||
sha2 = "0.11.0-rc.5"
|
||||
base16ct = { version = "1.0.0", features = ["alloc"] }
|
||||
rust-embed = { version = "8.7.2" }
|
||||
sha2 = "0.11.0-rc.4"
|
||||
base16ct = "0.2.0"
|
||||
httpdate = "1.0.3"
|
||||
chrono = "0.4.43"
|
||||
tempfile = "3.25.0"
|
||||
zip = "8.1.0"
|
||||
rust_xlsxwriter = "0.93.0"
|
||||
tempfile = "3.20.0"
|
||||
zip = "3.0.0"
|
||||
rust_xlsxwriter = "0.87.0"
|
||||
@@ -1,7 +1,6 @@
|
||||
use clap::Parser;
|
||||
use s3::creds::Credentials;
|
||||
use s3::{Bucket, Region};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
/// Money Manager backend API
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
@@ -133,13 +132,16 @@ pub struct AppConfig {
|
||||
pub apk_download_url: String,
|
||||
}
|
||||
|
||||
/// Cached application config
|
||||
static ARGS: OnceLock<AppConfig> = OnceLock::new();
|
||||
lazy_static::lazy_static! {
|
||||
static ref ARGS: AppConfig = {
|
||||
AppConfig::parse()
|
||||
};
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
/// Get parsed command line arguments
|
||||
pub fn get() -> &'static AppConfig {
|
||||
ARGS.get_or_init(AppConfig::parse)
|
||||
&ARGS
|
||||
}
|
||||
|
||||
/// Get auto login email (if not empty)
|
||||
|
||||
@@ -2,7 +2,8 @@ use crate::app_config::AppConfig;
|
||||
use diesel::PgConnection;
|
||||
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Arc;
|
||||
|
||||
const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
||||
@@ -19,13 +20,12 @@ fn get_db_connection_pool() -> anyhow::Result<DBConn> {
|
||||
))
|
||||
}
|
||||
|
||||
static DB_POOL: OnceLock<DBConn> = OnceLock::new();
|
||||
lazy_static! {
|
||||
static ref DB_POOL: DBConn = get_db_connection_pool().expect("Failed to connect to database");
|
||||
}
|
||||
|
||||
pub fn db() -> anyhow::Result<PooledConnection<ConnectionManager<PgConnection>>> {
|
||||
Ok(DB_POOL
|
||||
.get_or_init(|| get_db_connection_pool().expect("Failed to connect to database"))
|
||||
.clone()
|
||||
.get()?)
|
||||
Ok(DB_POOL.clone().get()?)
|
||||
}
|
||||
|
||||
pub fn initialize_conn() -> anyhow::Result<()> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::app_config::AppConfig;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::controllers::{HttpFailure, HttpResult};
|
||||
use crate::extractors::auth_extractor::{AuthExtractor, AuthenticatedMethod};
|
||||
use crate::extractors::money_session::MoneySession;
|
||||
use crate::services::{tokens_service, users_service};
|
||||
@@ -61,7 +61,9 @@ pub async fn finish_oidc(
|
||||
|
||||
let prov = AppConfig::get().openid_provider();
|
||||
|
||||
let conf = OpenIDConfig::load_from_url(prov.configuration_url).await?;
|
||||
let conf = OpenIDConfig::load_from_url(prov.configuration_url)
|
||||
.await
|
||||
.map_err(HttpFailure::OpenID)?;
|
||||
|
||||
let (token, _) = conf
|
||||
.request_token(
|
||||
@@ -70,8 +72,12 @@ pub async fn finish_oidc(
|
||||
&req.code,
|
||||
&AppConfig::get().oidc_redirect_url(),
|
||||
)
|
||||
.await?;
|
||||
let (user_info, _) = conf.request_user_info(&token).await?;
|
||||
.await
|
||||
.map_err(HttpFailure::OpenID)?;
|
||||
let (user_info, _) = conf
|
||||
.request_user_info(&token)
|
||||
.await
|
||||
.map_err(HttpFailure::OpenID)?;
|
||||
|
||||
if user_info.email_verified != Some(true) {
|
||||
log::error!("Email is not verified!");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::controllers::backup_controller::BackupControllerError;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{HttpResponse, ResponseError};
|
||||
use light_openid::errors::OpenIdError;
|
||||
use std::error::Error;
|
||||
use zip::result::ZipError;
|
||||
|
||||
pub mod accounts_controller;
|
||||
@@ -28,7 +28,7 @@ pub enum HttpFailure {
|
||||
#[error("an unhandled session error occurred")]
|
||||
SessionError(#[from] actix_session::SessionGetError),
|
||||
#[error("an unspecified open id error occurred: {0}")]
|
||||
OpenID(#[from] OpenIdError),
|
||||
OpenID(Box<dyn Error>),
|
||||
#[error("an unspecified internal error occurred: {0}")]
|
||||
InternalError(#[from] anyhow::Error),
|
||||
#[error("a serde_json error occurred: {0}")]
|
||||
|
||||
@@ -7,20 +7,3 @@ pub fn sha512(bytes: &[u8]) -> String {
|
||||
let h = hasher.finalize();
|
||||
base16ct::lower::encode_string(h.as_slice())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::utils::crypt_utils::sha512;
|
||||
|
||||
#[test]
|
||||
fn test_sha512() {
|
||||
assert_eq!(
|
||||
sha512(&[]),
|
||||
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
|
||||
);
|
||||
assert_eq!(
|
||||
sha512("hello".as_bytes()),
|
||||
"9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user