Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] Fix Apple ID 2FA with SMS #21072

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions spaceship/lib/spaceship/two_step_or_factor_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ def handle_two_step_for_device(device_id)

# Send token to server to get a valid session
r = request(:post) do |req|
req.url("https://idmsa.apple.com/appleauth/auth/verify/device/#{device_id}/securitycode")
req.url("https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i think the original url was correct, but your body was wrong.

In Xcodes - https://github.com/RobotsAndPencils/XcodesApp/blob/main/Xcodes/AppleAPI/Sources/AppleAPI/URLRequest%2BApple.swift#L68

Depending on if it's sms or device it'll send different bodies.

for SMS: verify/phone/securitycode

  req.body = {
          "phoneNumber": {
            "id": device_id
          },
          "securityCode": {
            "code" => code.to_s
          },
          "mode": "sms"

for trusted device: ``verify/trusteddevice/securitycode`

  req.body = {
          "securityCode": {
            "code" => code.to_s
          }

That hasn't changed for a while and has been working, but maybe that has changed now 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah yeah, the body definitely seemed wrong so not really sure how it didn't break sooner 🤷‍♂️

But... the new url/updated URL look correct though too, right? This is what proxyman showed me today 👇

Screenshot 2023-02-23 at 12 21 28 PM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is not many people use sms as their 2fa vs a trusted device

that Updated url looks correct for SMS 2FA. For trusted device it's:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah yeah, we have a separate path for trusted devices that uses that URL and body already 😊

👉 https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/two_step_or_factor_client.rb#L162-L170

req.headers['Content-Type'] = 'application/json'
req.body = { "code" => code.to_s }.to_json
req.body = {
"phoneNumber": {
"id": device_id
},
"securityCode": {
"code" => code.to_s
},
"mode": "sms"
}.to_json
update_request_headers(req)
end

Expand Down