Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit 7ee15ac

Browse files
committed
feat: microsoft authentication scheme
1 parent 7ddd596 commit 7ee15ac

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

src-tauri/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tauri = { version = "1.5", features = [ "api-all",
1818
serde = { version = "1.0", features = ["derive"] }
1919
serde_json = "1.0"
2020
zip = "0.6.6"
21+
once_cell = "1.19.0"
2122

2223
[features]
2324
# this feature is used for production builds or when `devPath` points to the filesystem

src-tauri/src/core/auth.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use tauri::Manager;
2+
3+
#[tauri::command]
4+
pub fn get_microsoft_auth_code(app_handle: tauri::AppHandle) {
5+
tauri::WindowBuilder::new(
6+
&app_handle,
7+
"oauth",
8+
tauri::WindowUrl::External(
9+
"https://login.live.com/oauth20_authorize.srf\
10+
?client_id=00000000402b5328\
11+
&response_type=code\
12+
&prompt=login\
13+
&scope=service%3A%3Auser.auth.xboxlive.com%3A%3AMBI_SSL\
14+
&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf"
15+
.parse()
16+
.unwrap(),
17+
),
18+
)
19+
.title("Log in to Microsoft...")
20+
.on_navigation(|url| {
21+
let prefix = "https://login.live.com/oauth20_desktop.srf?";
22+
let url = url.to_string();
23+
if url.starts_with(prefix) {
24+
let auth_code = url.replace(prefix, "");
25+
if let Some(app_handle) = crate::INSTANCE.get() {
26+
app_handle.emit_all("auth-code", auth_code).unwrap();
27+
if let Some(window) = app_handle.get_window("oauth") {
28+
window.close().unwrap();
29+
}
30+
}
31+
}
32+
true
33+
})
34+
.build()
35+
.unwrap();
36+
}

src-tauri/src/core/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
pub mod auth;
12
pub mod runner;
23
pub mod zip;

src-tauri/src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
22
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
33

4+
use once_cell::sync::OnceCell;
5+
use tauri::AppHandle;
6+
7+
pub static INSTANCE: OnceCell<AppHandle> = OnceCell::new();
8+
49
mod core;
510

611
fn main() {
712
tauri::Builder::default()
13+
.setup(|app| {
14+
INSTANCE.set(app.handle()).unwrap();
15+
Ok(())
16+
})
817
.invoke_handler(tauri::generate_handler![
918
core::zip::extract_zip,
10-
core::runner::run_minecraft
19+
core::runner::run_minecraft,
20+
core::auth::get_microsoft_auth_code,
1121
])
1222
.run(tauri::generate_context!())
1323
.expect("error while running tauri application");

0 commit comments

Comments
 (0)