[iOS] NativeLoginManager Basic-Auth header uses URL-safe Base64 instead of standard Base64, breaking login for some username/password combinations - #4161
Conversation
|
||||||||||||||||||
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4161 +/- ##
==========================================
- Coverage 71.47% 67.57% -3.91%
==========================================
Files 254 254
Lines 22868 22901 +33
==========================================
- Hits 16346 15475 -871
- Misses 6522 7426 +904
🚀 New features to boost your workflow:
|
|
||||||||||||||
wmathurin
approved these changes
Aug 31, 2026
… (Replace urlSafeBase64Encode with base64EncodedString in generateColonConcatenatedBase64String; add regression tests for login and submitPasswordlessAuthorizationRequest)
JohnsonEricAtSalesforce
force-pushed
the
bugfix/ios-nativeloginmanager-basic-auth-header-uses-url-safe-base64-instead-of-standard-base64-breaking-login-for-some-username-password-combinations
branch
from
August 31, 2026 20:08
4144f6b to
2551251
Compare
JohnsonEricAtSalesforce
merged commit Aug 31, 2026
ff4e588
into
forcedotcom:dev
22 of 24 checks passed
JohnsonEricAtSalesforce
deleted the
bugfix/ios-nativeloginmanager-basic-auth-header-uses-url-safe-base64-instead-of-standard-base64-breaking-login-for-some-username-password-combinations
branch
August 31, 2026 20:31
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
NativeLoginManagerInternal's helper for building the Basic-AuthAuthorizationheader (generateColonConcatenatedBase64String()) encoded the colon-concatenated username and password with the URL-safe Base64 alphabet and no padding (viaurlSafeBase64Encode()). HTTP Basic Authentication (RFC 7617) requires the standard Base64 alphabet with padding. For most credential pairs the two alphabets produce identical output, which is why this went unnoticed — they only diverge when the encoded bytes would contain+,/, or need=padding under the standard alphabet. When that happens, login fails with a generic "check your username and password" error even though the credentials are correct (confirmed working via web login for the same user).The equivalent fix already shipped on Android for the same defect class in its own Basic-Auth encoding helper; the iOS Swift implementation independently had the identical bug and that fix was never ported over.
generateColonConcatenatedBase64String()to encode with the standard Base64 alphabet (plaindata.base64EncodedString()) instead ofurlSafeBase64Encode().login(),submitAuthorizationRequest()(used by the OTP/registration-completion flows), andsubmitPasswordlessAuthorizationRequest()(OTP/passwordless login), so all three call sites are fixed by the one change.Scope note
This does not touch
urlSafeBase64Encode()'s other callers in the same file —generateCodeVerifier()andgenerateChallenge()— which correctly need URL-safe Base64 per RFC 7636 for PKCEcodeVerifier/codeChallengevalues and are unrelated to this HTTP Basic-Auth header.Test plan
login(), using a username/password pair whose combined UTF-8 bytes diverge between the standard and URL-safe alphabets (contains/and requires=padding under the standard alphabet); asserts theAuthorizationheader matches standard Base64 output.submitPasswordlessAuthorizationRequest()(a call site sharing the same helper), same divergent credential pair.NativeLoginManagerTestson the iOS simulator — both new tests pass. (Two pre-existing, unrelated failures in this suite —testShouldShowBackButton/testShouldShowBackButtonWithBioAuth— are keychain-entitlement issues in this local sandboxed environment, reproduced identically on unmodifieddev.)This response was generated by an AI agent on behalf of @JohnsonEricAtSalesforce.