Skip to content

Commit

Permalink
Further auth requests consistency fixes
Browse files Browse the repository at this point in the history
- Generated device UUIDs are lowercase, whereas they're uppercase in MCL
- TitleId in SISU authenticate is supposed to be a string (it is in MCL)
- UseModernGamertag in SISU authorize, on the other hand, is a boolean
- Clarified charset of our requests like MCL does
- Specified rng gen call to generate u8 to fix compile error (???)
  • Loading branch information
brawaru committed Apr 25, 2024
1 parent deedf4f commit f6eeeea
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions theseus/src/state/minecraft_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ async fn sisu_authenticate(
"RedirectUri": REDIRECT_URL,
"Sandbox": "RETAIL",
"TokenType": "code",
"TitleId": 1794566092,
"TitleId": "1794566092",
}),
key,
MinecraftAuthStep::SisuAuthenicate,
Expand Down Expand Up @@ -581,7 +581,7 @@ async fn sisu_authorize(
"SessionId": session_id,
"SiteName": "user.auth.xboxlive.com",
"RelyingParty": "http://xboxlive.com",
"UseModernGamertag": "true"
"UseModernGamertag": true
}),
key,
MinecraftAuthStep::SisuAuthorize,
Expand Down Expand Up @@ -781,7 +781,7 @@ pub struct DeviceTokenKey {

#[tracing::instrument]
fn generate_key() -> Result<DeviceTokenKey, MinecraftAuthenticationError> {
let id = Uuid::new_v4().to_string();
let id = Uuid::new_v4().to_string().to_uppercase();

let signing_key = SigningKey::random(&mut OsRng);
let public_key = VerifyingKey::from(&signing_key);
Expand Down Expand Up @@ -879,9 +879,9 @@ async fn send_signed_request<T: DeserializeOwned>(
let res = auth_retry(|| {
let mut request = REQWEST_CLIENT
.post(url)
.header("Content-Type", "application/json")
.header("Content-Type", "application/json; charset=utf-8")
.header("Accept", "application/json")
.header("signature", &signature);
.header("Signature", &signature);

if url != "https://sisu.xboxlive.com/authorize" {
request = request.header("x-xbl-contract-version", "1");
Expand Down Expand Up @@ -915,6 +915,6 @@ async fn send_signed_request<T: DeserializeOwned>(
fn generate_oauth_challenge() -> String {
let mut rng = rand::thread_rng();

let bytes: Vec<u8> = (0..64).map(|_| rng.gen()).collect();
let bytes: Vec<u8> = (0..64).map(|_| rng.gen::<u8>()).collect();
bytes.iter().map(|byte| format!("{:02x}", byte)).collect()
}

0 comments on commit f6eeeea

Please sign in to comment.