Skip to content

Commit

Permalink
Further auth requests consistency fixes (#1149)
Browse files Browse the repository at this point in the history
* Further auth requests consistency fixes

- 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 (???)

* Enable deflate, gzip and brotli compression support
  • Loading branch information
brawaru authored Apr 25, 2024
1 parent deedf4f commit 4de64d9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
30 changes: 27 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion theseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ indicatif = { version = "0.17.3", optional = true }

async-tungstenite = { version = "0.25.1", features = ["tokio-runtime", "tokio-native-tls"] }
futures = "0.3"
reqwest = { version = "0.12.3", features = ["json", "stream"] }
reqwest = { version = "0.12.3", features = ["json", "stream", "deflate", "gzip", "brotli"] }
tokio = { version = "1", features = ["full"] }
tokio-stream = { version = "0.1", features = ["fs"] }
async-recursion = "1.0.4"
Expand Down
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 4de64d9

Please sign in to comment.