Skip to content

Commit 800764c

Browse files
mattleibowCopilot
andcommitted
Fix iOS keychain config for MSAL token persistence
Align iOS keychain-access-groups entitlement with Mac Catalyst to use com.microsoft.adalcache (MSAL's default shared keychain group). Add WithIosKeychainSecurityGroup to the MSAL builder for iOS and Mac Catalyst so tokens persist correctly across app restarts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b1e7606 commit 800764c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

10.0/MauiBlazorWebEntra/MauiBlazorWebEntra/Platforms/iOS/Entitlements.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<dict>
55
<key>keychain-access-groups</key>
66
<array>
7-
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
7+
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
88
</array>
99
</dict>
1010
</plist>

10.0/MauiBlazorWebEntra/MauiBlazorWebEntra/Services/MsalServiceExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public static IServiceCollection AddMsalClient(this IServiceCollection services)
1515
var msalBuilder = PublicClientApplicationBuilder
1616
.Create(MsalConfig.ClientId)
1717
.WithAuthority(MsalConfig.Authority)
18-
.WithRedirectUri(MsalConfig.RedirectUri);
18+
.WithRedirectUri(MsalConfig.RedirectUri)
19+
#if IOS || MACCATALYST
20+
.WithIosKeychainSecurityGroup("com.microsoft.adalcache")
21+
#endif
22+
;
1923

2024
#if WINDOWS
2125
// Windows: use embedded WebView2 browser + WAM broker for authentication.

0 commit comments

Comments
 (0)