Skip to content

Commit

Permalink
improved microsoft authentication
Browse files Browse the repository at this point in the history
- fixed refresh token issue with miners library (see CCBlueX/mine-rs@dcb0430)
- removed auth cache file and now serializing into config (less secure, but not hard to reverse anyway)
- added support for old auth cache file to be read and turned into new format
  • Loading branch information
1zun4 committed Jun 7, 2023
1 parent 702e28a commit 4da0a94
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 102 deletions.
119 changes: 49 additions & 70 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.7.2"

# Support for the old authentication file
base64 = { version = "0.13" }
byteorder = { version = "1.4" }

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
Expand Down
7 changes: 5 additions & 2 deletions src-tauri/src/app/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async fn run_client(build_id: u32, account_data: MinecraftAccount, options: Laun
let window_mutex = Arc::new(std::sync::Mutex::new(window));

let (account_name, uuid, token, user_type) = match account_data {
MinecraftAccount::MsaAccount { auth, .. } => (auth.name, auth.uuid, auth.token, "msa".to_string()),
MinecraftAccount::MsaAccount { name, uuid, token, .. } => (name, uuid, token, "msa".to_string()),
MinecraftAccount::OfflineAccount { name, uuid } => (name, "-".to_string(), uuid, "legacy".to_string())
};

Expand Down Expand Up @@ -221,7 +221,10 @@ async fn terminate(app_state: tauri::State<'_, AppState>) -> Result<(), String>
#[tauri::command]
async fn refresh(account_data: MinecraftAccount) -> Result<MinecraftAccount, String> {
let account = account_data.refresh().await
.map_err(|e| format!("unable to refresh: {:?}", e))?;
.map_err(|e| {
error!("unable to refresh: {:?}", e);
format!("unable to refresh: {:?}", e)
})?;
Ok(account)
}

Expand Down
Loading

0 comments on commit 4da0a94

Please sign in to comment.