Skip to content

Commit de10c36

Browse files
committed
Fix GSA
1 parent d4c0351 commit de10c36

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ jobs:
1212
name: ${{ matrix.os }} with ${{ matrix.features }}
1313
runs-on: ${{ matrix.os }}
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
1618
- uses: actions-rs/toolchain@v1
1719
with:
1820
toolchain: stable

icloud-auth/src/client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use srp::{
1616
client::{SrpClient, SrpClientVerifier},
1717
groups::G_2048,
1818
};
19-
use log::{debug, error, warn};
19+
use log::{debug, error, info, warn};
2020
use tokio::sync::Mutex;
2121
use uuid::Uuid;
2222

@@ -175,6 +175,7 @@ pub struct TrustedPhoneNumber {
175175
#[derive(Deserialize)]
176176
#[serde(rename_all = "camelCase")]
177177
pub struct AuthenticationExtras {
178+
#[serde(default)]
178179
pub trusted_phone_numbers: Vec<TrustedPhoneNumber>,
179180
pub recovery_url: Option<String>,
180181
pub cant_use_phone_number_url: Option<String>,
@@ -809,7 +810,12 @@ impl<T: AnisetteProvider> AppleAccount<T> {
809810
warn!("Got auth response {}", base64::encode(&body));
810811
return Err(Error::FailedGetting2FAConfig);
811812
}
812-
let mut new_state = req.json::<AuthenticationExtras>().await?;
813+
let resp = req.bytes().await?;
814+
info!("Got gsa auth extras {:?}", str::from_utf8(&resp).unwrap());
815+
let mut new_state: AuthenticationExtras = serde_json::from_slice(&resp)?;
816+
if new_state.trusted_phone_numbers.is_empty() {
817+
return Err(Error::HardwareKeyError);
818+
}
813819
if status == 201 {
814820
new_state.new_state = Some(LoginState::NeedsSMS2FAVerification(VerifyBody {
815821
phone_number: PhoneNumber {

icloud-auth/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ pub enum Error {
3030
ErrorGettingAnisette(#[from] omnisette::AnisetteError),
3131
#[error("Disable Advanced Data Protection")]
3232
FailedGetting2FAConfig,
33+
#[error("Serde Error")]
34+
SerdeError(#[from] serde_json::Error),
35+
#[error("Disable hardware authentication keys and try again!")]
36+
HardwareKeyError,
3337
}

0 commit comments

Comments
 (0)