Skip to content

fix(auth): preserve per-user AA flag on token refresh (W-23616382) - #4124

Open
wmathurin wants to merge 1 commit into
forcedotcom:devfrom
wmathurin:W-23616382-ios-aa-refresh-bug
Open

fix(auth): preserve per-user AA flag on token refresh (W-23616382)#4124
wmathurin wants to merge 1 commit into
forcedotcom:devfrom
wmathurin:W-23616382-ios-aa-refresh-bug

Conversation

@wmathurin

Copy link
Copy Markdown
Contributor

Summary

  • Moves the AA (App Attestation) per-user promotion block inside the completedAuthType != SFOAuthTypeRefresh guard in finalizeAuthCompletion: in SFUserAccountManager.m
  • Silent token refreshes previously ran the promotion block unconditionally, calling unregisterAppFeature:forUser: when the transient global was absent — silently clearing the persisted AA flag on every refresh
  • The global clear (unregisterAppFeature:kSFAppFeatureAppAttestation) fires unconditionally outside the guard, as intended
  • WD and QR were already correctly placed inside the guard; this brings AA into alignment with them

Test plan

  • SFSDKAppFeatureMarkersTests — all 22 tests pass (verified locally)
  • test_givenAAFlagPersistedOnUser_whenTokenRefreshCompletes_thenAAFlagPreserved — new regression test
  • test_givenAARegisteredGlobally_whenNonRefreshLoginCompletes_thenAAPromotedToUserAndGlobalCleared — new regression test
  • Verify AA appears correctly in user agent after app restart following attestation login
  • Verify AA persists across silent token refreshes (remains in user agent)

GUS: W-23616382

Move the AA transient-global→per-user promotion block inside the
`completedAuthType != SFOAuthTypeRefresh` guard in
`finalizeAuthCompletion:`, so silent token refreshes never unregister
the persisted AA flag. The global clear fires unconditionally outside
the guard as before.

WD and QR are already correctly placed inside the guard; this fix
brings AA into line with them.

Add two regression tests in SFSDKAppFeatureMarkersTests:
- test_givenAAFlagPersistedOnUser_whenTokenRefreshCompletes_thenAAFlagPreserved
- test_givenAARegisteredGlobally_whenNonRefreshLoginCompletes_thenAAPromotedToUserAndGlobalCleared
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
1 Warning
⚠️ Static Analysis found an issue with one or more files you modified. Please fix the issue(s).

Clang Static Analysis Issues

File Type Category Description Line Col
SFUserAccountManager Nullability Memory error Null passed to a callee that requires a non-null 2nd parameter 1622 15
SFUserAccountManager Nullability Memory error Null passed to a callee that requires a non-null 2nd parameter 1637 15
SFUserAccountManager Nullability Memory error nil passed to a callee that requires a non-null 2nd parameter 2477 13

Generated by 🚫 Danger

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
TestsPassedSkippedFailed ❌️
AuthFlowTester UI Test Results all1 ran1 ❌
TestResult
AuthFlowTester UI Test Results all
AuthFlowTesterUITests.xctest
LegacyLoginTests.testCAOpaque_DefaultScopes_WebServerFlow()❌ failure

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.16%. Comparing base (76821d7) to head (0d27102).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 0.00% 6 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4124      +/-   ##
==========================================
- Coverage   71.35%   67.16%   -4.19%     
==========================================
  Files         254      254              
  Lines       22557    22557              
==========================================
- Hits        16095    15150     -945     
- Misses       6462     7407     +945     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 70.88% <ø> (-0.19%) ⬇️
Core 60.55% <0.00%> (-6.32%) ⬇️
SmartStore 73.44% <ø> (ø)
MobileSync 88.82% <ø> (ø)
Files with missing lines Coverage Δ
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 49.63% <0.00%> (-14.87%) ⬇️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
SalesforceSDKCore iOS ^18 Test Results945 ran945 ✅
TestResult
No test annotations available

@sfdctaka sfdctaka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants