Fix where apple is setting the service key now - #6
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates XcodesLoginKit’s Apple service-key resolution to follow the approach introduced in fastlane/fastlane#30206.
Apple’s legacy App Store Connect Olympus configuration endpoint now returns
404, making the previous widget-key lookup unreliable. Apple currently exposes the activewidgetKeythrough the unauthenticated App Store Connect/logoutredirect.This PR removes the hardcoded service key and introduces a cached, multi-source resolver that can discover Apple’s current key without requiring an XcodesLoginKit release whenever Apple rotates it.
Service-key resolution order
On the first resolution attempt, XcodesLoginKit now tries:
AppleServiceKeyProvider, when configured.widgetKeyfrom App Store Connect’s unauthenticated/logoutredirect.Once resolved, the key is retained in the resolver’s in-memory cache for subsequent authentication requests.
Successful automatic lookups are also written to disk. Cache read and write failures are logged but do not prevent authentication.
App Store Connect redirect lookup
The new primary automatic lookup performs:
Apple responds with a redirect similar to:
XcodesLoginKit extracts
widgetKeyfrom theLocationheader without following the redirect.Sign-out safety
The redirect ultimately performs a real sign-out, so the lookup uses a dedicated ephemeral
URLSessionconfigured to:This prevents service-key discovery from accidentally invalidating an existing Apple session.
Hardcoded key removal
The bundled hardcoded App Store Connect widget key has been removed.
A stale hardcoded key can appear to work through SRP and two-factor authentication, only for Apple to reject the resulting session later with an unrelated
401. Resolving Apple’s current key up front avoids that misleading failure and supports future key rotations without requiring a library update.Applications can still override discovery explicitly:
Dynamic configuration providers remain supported:
Typed failure reporting
Service-key failures now preserve information about every attempted source:
Each
AppleServiceKeyAttemptcontains:Possible failure reasons include:
Example localized error:
Authentication failures that happen after a key has been resolved are no longer caught and incorrectly reported as service-key resolution failures.
Error-handling behavior
Expected transport and parsing failures from the sign-out lookup fall through to Olympus.
Unexpected local or programming errors are preserved and rethrown instead of being swallowed as fallback failures. Task cancellation is also propagated immediately and does not trigger another network request.
This follows Fastlane’s approach of avoiding broad error handling around the lookup path.
Concurrency
The resolver is implemented as an actor so its in-memory key state is concurrency-safe.
Provider and network loaders are
@Sendable, and cancellation is checked between asynchronous operations. The no-redirect session delegate is stateless, with its uncheckedSendableconformance documented.Documentation
The README now documents:
Tests
Added and updated coverage for:
widgetKeyfrom the App Store Connect redirect.HEADfor the logout request.Locationheader.Verification
swift testXCODES_LOGIN_KIT_LIVE_SERVICE_KEY_TEST=1 swift test --filter testLiveAppStoreConnectSignOutRedirectContainsServiceKeyswift build -c releasegit diff --checkThe live test confirmed that the exact Swift no-cookie/no-redirect code path currently retrieves a valid 32–64 character lowercase hexadecimal widget key from Apple. No Apple ID credentials are required for this lookup.