Skip to content

Commit 00e7c8c

Browse files
authored
Merge branch 'master' into jmprieur/removingUis
2 parents 45b1750 + b940672 commit 00e7c8c

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
/Microsoft.Identity.Web.UI/bin
1313
/Microsoft.Identity.Web.UI/obj
1414
/Microsoft.Identity.Web.Test/.vs
15+
/Microsoft.Identity.Web.UI/bin
16+
/Microsoft.Identity.Web.UI/obj
1517
/Microsoft.Identity.Web.Test/bin
1618
/Microsoft.Identity.Web.Test/obj
1719
/1-WebApp-OIDC/1-1-MyOrg/.vs
@@ -117,7 +119,6 @@
117119
/4-WebApp-your-API/Client/obj
118120
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/bin
119121
/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/obj
120-
/Microsoft.Identity.Web.Test/obj
121122
/4-WebApp-your-API/4-1-MyOrg/.vs
122123
/4-WebApp-your-API/4-1-MyOrg/Client/bin
123124
/4-WebApp-your-API/4-1-MyOrg/Client/obj

Microsoft.Identity.Web/Microsoft.Identity.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.1" />
5858
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="3.1.1" />
5959
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.1" />
60-
<PackageReference Include="Microsoft.Identity.Client" Version="4.8.1" />
60+
<PackageReference Include="Microsoft.Identity.Client" Version="4.8.2" />
6161
</ItemGroup>
6262
</Project>

Microsoft.Identity.Web/WebAppServiceCollectionExtensions.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,50 @@ public static AuthenticationBuilder AddSignIn(
308308

309309
return builder;
310310
}
311+
312+
313+
// Method taken from https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/
314+
public static bool DisallowsSameSiteNone(string userAgent)
315+
{
316+
if (string.IsNullOrEmpty(userAgent))
317+
{
318+
return false;
319+
}
320+
321+
// Cover all iOS based browsers here. This includes:
322+
// - Safari on iOS 12 for iPhone, iPod Touch, iPad
323+
// - WkWebview on iOS 12 for iPhone, iPod Touch, iPad
324+
// - Chrome on iOS 12 for iPhone, iPod Touch, iPad
325+
// All of which are broken by SameSite=None, because they use the iOS networking
326+
// stack.
327+
if (userAgent.Contains("CPU iPhone OS 12") ||
328+
userAgent.Contains("iPad; CPU OS 12"))
329+
{
330+
return true;
331+
}
332+
333+
// Cover Mac OS X based browsers that use the Mac OS networking stack.
334+
// This includes:
335+
// - Safari on Mac OS X.
336+
// This does not include:
337+
// - Chrome on Mac OS X
338+
// Because they do not use the Mac OS networking stack.
339+
if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") &&
340+
userAgent.Contains("Version/") && userAgent.Contains("Safari"))
341+
{
342+
return true;
343+
}
344+
345+
// Cover Chrome 50-69, because some versions are broken by SameSite=None,
346+
// and none in this range require it.
347+
// Note: this covers some pre-Chromium Edge versions,
348+
// but pre-Chromium Edge does not require SameSite=None.
349+
if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6"))
350+
{
351+
return true;
352+
}
353+
354+
return false;
355+
}
311356
}
312357
}

0 commit comments

Comments
 (0)