From 4900a2ede773cb579207ad27ee73e2ffee943e87 Mon Sep 17 00:00:00 2001 From: Yoav Shai Date: Sat, 15 Jan 2022 02:21:36 +0200 Subject: [PATCH 1/5] Make WebCookie optional in Session The maFile from Steam Desktop Authenticator may set this field to null --- steamguard/src/steamapi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/steamguard/src/steamapi.rs b/steamguard/src/steamapi.rs index 19ea1c1..d57d961 100644 --- a/steamguard/src/steamapi.rs +++ b/steamguard/src/steamapi.rs @@ -99,7 +99,7 @@ pub struct Session { #[serde(rename = "SteamLoginSecure")] pub steam_login_secure: String, #[serde(default, rename = "WebCookie")] - pub web_cookie: String, + pub web_cookie: Option, #[serde(rename = "OAuthToken")] pub token: String, #[serde(rename = "SteamID")] @@ -153,7 +153,7 @@ impl SteamApiClient { session_id: self .extract_session_id() .expect("failed to extract session id from cookies"), - web_cookie: data.webcookie.clone(), + web_cookie: Some(data.webcookie.clone()), }; } From a48ada225273794b36720a60aeafb460f2bf9078 Mon Sep 17 00:00:00 2001 From: Yoav Shai Date: Sat, 15 Jan 2022 14:22:50 +0200 Subject: [PATCH 2/5] Add test case for maFile with null WebCookie --- src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile | 1 + src/fixtures/maFiles/compat/1-account/manifest.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile diff --git a/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile b/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile new file mode 100644 index 0000000..038907a --- /dev/null +++ b/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile @@ -0,0 +1 @@ +{"shared_secret":"zvIayp3JPvtvX/QGHqsqKBk/44s=","serial_number":"kljasfhds","revocation_code":"R12345","uri":"otpauth://totp/Steam:example?secret=ASDF&issuer=Steam","server_time":1602522478,"account_name":"example","token_gid":"jkkjlhkhjgf","identity_secret":"kjsdlwowiqe=","secret_1":"sklduhfgsdlkjhf=","status":1,"device_id":"android:99d2ad0e-4bad-4247-b111-26393aae0be3","fully_enrolled":true,"Session":{"SessionID":"a;lskdjf","SteamLogin":"983498437543","SteamLoginSecure":"dlkjdsl;j%7C%32984730298","WebCookie":null,"OAuthToken":"asdk;lf;dsjlkfd","SteamID":1234}} \ No newline at end of file diff --git a/src/fixtures/maFiles/compat/1-account/manifest.json b/src/fixtures/maFiles/compat/1-account/manifest.json index 7c2ed9f..0135d37 100644 --- a/src/fixtures/maFiles/compat/1-account/manifest.json +++ b/src/fixtures/maFiles/compat/1-account/manifest.json @@ -1 +1 @@ -{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"1234.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file +{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"1234.maFile","steamid":1234},{"encryption_iv":null,"encryption_salt":null,"filename":"1234_NoWebCookie.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file From 669d8e4dad2533aa9b64aedeef8bab8327458704 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 15 Jan 2022 09:23:21 -0500 Subject: [PATCH 3/5] Revert "Add test case for maFile with null WebCookie" This reverts commit a48ada225273794b36720a60aeafb460f2bf9078. --- src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile | 1 - src/fixtures/maFiles/compat/1-account/manifest.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile diff --git a/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile b/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile deleted file mode 100644 index 038907a..0000000 --- a/src/fixtures/maFiles/compat/1-account/1234_NoWebCookie.maFile +++ /dev/null @@ -1 +0,0 @@ -{"shared_secret":"zvIayp3JPvtvX/QGHqsqKBk/44s=","serial_number":"kljasfhds","revocation_code":"R12345","uri":"otpauth://totp/Steam:example?secret=ASDF&issuer=Steam","server_time":1602522478,"account_name":"example","token_gid":"jkkjlhkhjgf","identity_secret":"kjsdlwowiqe=","secret_1":"sklduhfgsdlkjhf=","status":1,"device_id":"android:99d2ad0e-4bad-4247-b111-26393aae0be3","fully_enrolled":true,"Session":{"SessionID":"a;lskdjf","SteamLogin":"983498437543","SteamLoginSecure":"dlkjdsl;j%7C%32984730298","WebCookie":null,"OAuthToken":"asdk;lf;dsjlkfd","SteamID":1234}} \ No newline at end of file diff --git a/src/fixtures/maFiles/compat/1-account/manifest.json b/src/fixtures/maFiles/compat/1-account/manifest.json index 0135d37..7c2ed9f 100644 --- a/src/fixtures/maFiles/compat/1-account/manifest.json +++ b/src/fixtures/maFiles/compat/1-account/manifest.json @@ -1 +1 @@ -{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"1234.maFile","steamid":1234},{"encryption_iv":null,"encryption_salt":null,"filename":"1234_NoWebCookie.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file +{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"1234.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file From 070be5b629bc633bd9af9d355f5d4945702335c6 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 15 Jan 2022 09:24:12 -0500 Subject: [PATCH 4/5] re-add no webcookie test fixture as a seperate fixture --- src/fixtures/maFiles/compat/no-webcookie/manifest.json | 1 + src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile | 1 + 2 files changed, 2 insertions(+) create mode 100644 src/fixtures/maFiles/compat/no-webcookie/manifest.json create mode 100644 src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile diff --git a/src/fixtures/maFiles/compat/no-webcookie/manifest.json b/src/fixtures/maFiles/compat/no-webcookie/manifest.json new file mode 100644 index 0000000..0e6c961 --- /dev/null +++ b/src/fixtures/maFiles/compat/no-webcookie/manifest.json @@ -0,0 +1 @@ +{"encrypted":false,"first_run":true,"entries":[{"encryption_iv":null,"encryption_salt":null,"filename":"nowebcookie.maFile","steamid":1234}],"periodic_checking":false,"periodic_checking_interval":5,"periodic_checking_checkall":false,"auto_confirm_market_transactions":false,"auto_confirm_trades":false} \ No newline at end of file diff --git a/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile b/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile new file mode 100644 index 0000000..038907a --- /dev/null +++ b/src/fixtures/maFiles/compat/no-webcookie/nowebcookie.maFile @@ -0,0 +1 @@ +{"shared_secret":"zvIayp3JPvtvX/QGHqsqKBk/44s=","serial_number":"kljasfhds","revocation_code":"R12345","uri":"otpauth://totp/Steam:example?secret=ASDF&issuer=Steam","server_time":1602522478,"account_name":"example","token_gid":"jkkjlhkhjgf","identity_secret":"kjsdlwowiqe=","secret_1":"sklduhfgsdlkjhf=","status":1,"device_id":"android:99d2ad0e-4bad-4247-b111-26393aae0be3","fully_enrolled":true,"Session":{"SessionID":"a;lskdjf","SteamLogin":"983498437543","SteamLoginSecure":"dlkjdsl;j%7C%32984730298","WebCookie":null,"OAuthToken":"asdk;lf;dsjlkfd","SteamID":1234}} \ No newline at end of file From d21ceef797783f1208f648c04e67e302994888da Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 15 Jan 2022 09:36:10 -0500 Subject: [PATCH 5/5] add sda compat unit test for no web cookie --- src/accountmanager.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/accountmanager.rs b/src/accountmanager.rs index e389f7b..a9a0915 100644 --- a/src/accountmanager.rs +++ b/src/accountmanager.rs @@ -482,4 +482,38 @@ mod tests { .account_name ); } + + #[test] + fn test_sda_compatibility_no_webcookie() { + let path = Path::new("src/fixtures/maFiles/compat/no-webcookie/manifest.json"); + assert!(path.is_file()); + let result = Manifest::load(path); + assert!(matches!(result, Ok(_))); + let mut manifest = result.unwrap(); + assert!(matches!(manifest.entries.last().unwrap().encryption, None)); + assert!(matches!(manifest.load_accounts(&None), Ok(_))); + assert_eq!( + manifest.entries.last().unwrap().account_name, + manifest + .accounts + .last() + .unwrap() + .lock() + .unwrap() + .account_name + ); + assert_eq!( + manifest + .accounts + .last() + .unwrap() + .lock() + .unwrap() + .session + .as_ref() + .unwrap() + .web_cookie, + None + ); + } }