Let Rojo pull auth cookie from registry on Windows

This commit is contained in:
Lucien Greathouse
2019-08-28 13:21:30 -07:00
parent e5575b782c
commit 8fe1fa48b8
6 changed files with 59 additions and 8 deletions

30
src/auth_cookie.rs Normal file
View File

@@ -0,0 +1,30 @@
//! Implementation of automatically fetching authentication cookie from a Roblox
//! Studio installation.
#[cfg(windows)]
pub fn get_auth_cookie() -> Option<String> {
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
let hkcu = RegKey::predef(HKEY_CURRENT_USER);
let cookies = hkcu
.open_subkey("Software\\Roblox\\RobloxStudioBrowser\\roblox.com")
.ok()?;
let entry: String = cookies.get_value(".ROBLOSECURITY").ok()?;
let mut cookie = None;
for kv_pair in entry.split(",") {
let mut pieces = kv_pair.split("::");
if let Some("COOK") = pieces.next() {
cookie = pieces.next();
}
}
cookie.map(Into::into)
}
#[cfg(not(windows))]
pub fn get_auth_cookie() -> Option<String> {
None
}