From 4cef62e8e4aa04e44048eb67e5091c12a73d2a09 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 16 Oct 2022 22:54:54 -0500 Subject: Microsoft Authentication (#29) * a * try to do more work on auth signing (untested) * well auth works when i remove the d= so * auth stuff * sessionserver stuff * add auth in azalea-protocol/client * caching* refreshing microsoft auth tokens isn't implemented yet, also i haven't tested it * how did i not notice that i had the code duplicated * fix cache * add refreshing msa token * replace some printlns with log::trace * auth works! * Update main.rs * fix clippy warnings --- azalea-client/src/get_mc_dir.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 azalea-client/src/get_mc_dir.rs (limited to 'azalea-client/src/get_mc_dir.rs') diff --git a/azalea-client/src/get_mc_dir.rs b/azalea-client/src/get_mc_dir.rs new file mode 100644 index 00000000..abc5b3c8 --- /dev/null +++ b/azalea-client/src/get_mc_dir.rs @@ -0,0 +1,34 @@ +//! Find out where the user's .minecraft directory is. +//! +//! Used for the auth cache. + +use std::path::PathBuf; + +/// Return the location of the user's .minecraft directory. +/// +/// Windows: `%appdata%\.minecraft`\ +/// Mac: `$HOME/Library/Application Support/minecraft`\ +/// Linux: `$HOME/.minecraft` +/// +/// Anywhere else it'll return None. +pub fn minecraft_dir() -> Option { + #[cfg(target_os = "windows")] + { + let appdata = std::env::var("APPDATA").ok()?; + Some(PathBuf::from(appdata).join(".minecraft")) + } + #[cfg(target_os = "macos")] + { + let home = std::env::var("HOME").ok()?; + Some(PathBuf::from(home).join("Library/Application Support/minecraft")) + } + #[cfg(target_os = "linux")] + { + let home = std::env::var("HOME").ok()?; + Some(PathBuf::from(home).join(".minecraft")) + } + #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))] + { + None + } +} -- cgit v1.2.3