diff --git a/proto/out/bin.rs b/proto/out/bin.rs index 5a0f9a1..73bc372 100644 --- a/proto/out/bin.rs +++ b/proto/out/bin.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PlayerBasicCompBin { diff --git a/sdkserver/sdkserver.json b/sdkserver/sdkserver.json index c2f10df..9adef00 100644 --- a/sdkserver/sdkserver.json +++ b/sdkserver/sdkserver.json @@ -1,6 +1,7 @@ { "http_port": 21000, "dispatch_endpoint": "http://127.0.0.1:21041", + "disable_password_check": false, "database": { "connection_string": "mongodb://127.0.0.1:27017", "name": "FireflySR", diff --git a/sdkserver/src/config.rs b/sdkserver/src/config.rs index 4440fd2..6ea7a28 100644 --- a/sdkserver/src/config.rs +++ b/sdkserver/src/config.rs @@ -14,6 +14,7 @@ pub struct SDKServerConfiguration { pub http_port: u16, pub dispatch_endpoint: String, pub database: DatabaseConfig, + pub disable_password_check: bool, } lazy_static! { diff --git a/sdkserver/src/services/mdk_shield.rs b/sdkserver/src/services/mdk_shield.rs index 44a4538..16e9655 100644 --- a/sdkserver/src/services/mdk_shield.rs +++ b/sdkserver/src/services/mdk_shield.rs @@ -3,7 +3,7 @@ use common::document::AccountDocument; use serde::Deserialize; use serde_json::json; -use crate::{database, util, SdkContext}; +use crate::{config::CONFIGURATION, database, util, SdkContext}; const LOGIN: &str = "/:product_name/mdk/shield/api/login"; const VERIFY: &str = "/:product_name/mdk/shield/api/verify"; @@ -38,9 +38,15 @@ async fn login( ); } - let Ok(password) = util::decrypt_string(&request.password) else { - return fail_json(-10, "Your patch is outdated.\r\nGet new one at https://discord.gg/reversedrooms\r\n(Password decryption failed)"); - }; + let mut password_opt: Option = None; + if !CONFIGURATION.disable_password_check + { + if let Ok(password) = util::decrypt_string(&request.password) { + password_opt = Some(password); + } else { + return fail_json(-10, "Your patch is outdated.\r\nGet new one at https://discord.gg/reversedrooms\r\n(Password decryption failed)"); + }; + } let account = match database::get_account_by_name(&context.db_client, &request.account).await { Ok(Some(account)) => account, @@ -48,7 +54,7 @@ async fn login( Err(_) => return fail_json(-1, "Internal server error"), }; - if util::verify_password(&password, &account.account_password).is_err() { + if CONFIGURATION.disable_password_check || util::verify_password(&password_opt.unwrap(), &account.account_password).is_err() { return fail_json(-101, "Account or password error"); }