Skip to content

Commit 3365477

Browse files
authored
Merge pull request #60880 from vseanreesermsft/internal-merge-9.0-2025-03-11-1249
Merging internal commits for release/9.0
2 parents cd7e571 + d2e5dd7 commit 3365477

File tree

9 files changed

+334
-265
lines changed

9 files changed

+334
-265
lines changed

.azure/pipelines/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ variables:
9797
- name: WindowsArm64InstallersLogArgs
9898
value: /bl:artifacts/log/Release/Build.Installers.Arm64.binlog
9999
- name: _InternalRuntimeDownloadArgs
100-
value: -RuntimeSourceFeed https://dotnetbuilds.blob.core.windows.net/internal
100+
value: -RuntimeSourceFeed https://ci.dot.net/internal
101101
-RuntimeSourceFeedKey $(dotnetbuilds-internal-container-read-token-base64)
102102
/p:DotNetAssetRootAccessTokenSuffix='$(dotnetbuilds-internal-container-read-token-base64)'
103103
# The code signing doesn't use the aspnet build scripts, so the msbuild parameters have to be passed directly. This
104104
# is awkward but necessary because the eng/common/ build scripts don't add the msbuild properties automatically.
105105
- name: _InternalRuntimeDownloadCodeSignArgs
106106
value: $(_InternalRuntimeDownloadArgs)
107-
/p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal
107+
/p:DotNetRuntimeSourceFeed=https://ci.dot.net/internal
108108
/p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64)
109109
- group: DotNet-HelixApi-Access
110110
- ${{ if notin(variables['Build.Reason'], 'PullRequest') }}:

NuGet.config

+4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
<clear />
55
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
66
<!-- Begin: Package sources from dotnet-runtime -->
7+
<add key="darc-int-dotnet-runtime-831d23e" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-831d23e5/nuget/v3/index.json" />
78
<!-- End: Package sources from dotnet-runtime -->
89
<!-- Begin: Package sources from dotnet-efcore -->
10+
<add key="darc-int-dotnet-efcore-68c7e19" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-68c7e194/nuget/v3/index.json" />
911
<!-- End: Package sources from dotnet-efcore -->
1012
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
1113
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
@@ -28,8 +30,10 @@
2830
<clear />
2931
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
3032
<!-- Begin: Package sources from dotnet-efcore -->
33+
<add key="darc-int-dotnet-efcore-68c7e19" value="true" />
3134
<!-- End: Package sources from dotnet-efcore -->
3235
<!-- Begin: Package sources from dotnet-runtime -->
36+
<add key="darc-int-dotnet-runtime-831d23e" value="true" />
3337
<!-- End: Package sources from dotnet-runtime -->
3438
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
3539
</disabledPackageSources>

eng/Version.Details.xml

+160-160
Large diffs are not rendered by default.

eng/Versions.props

+80-80
Large diffs are not rendered by default.

eng/helix/helix.proj

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
<PackageType>runtime</PackageType>
5959
</AdditionalDotNetPackage>
6060

61-
<AdditionalDotNetPackageFeed Include="https://dotnetbuilds.blob.core.windows.net/internal"
61+
<AdditionalDotNetPackageFeed Include="https://ci.dot.net/internal"
6262
Condition="'$(SYSTEM_TEAMPROJECT)' == 'internal'">
6363
<SasToken>$([System.Environment]::GetEnvironmentVariable('DotNetBuildsInternalReadSasToken'))</SasToken>
6464
</AdditionalDotNetPackageFeed>
6565

66-
<AdditionalDotNetPackageFeed Include="https://dotnetbuilds.blob.core.windows.net/internal"
66+
<AdditionalDotNetPackageFeed Include="https://ci.dot.net/internal"
6767
Condition="'$(SYSTEM_TEAMPROJECT)' == 'internal'">
6868
<SasToken>$([System.Environment]::GetEnvironmentVariable('DotNetBuildsInternalReadSasToken'))</SasToken>
6969
</AdditionalDotNetPackageFeed>

src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
560560
<!-- Try various places to find the runtime. It's either released (use official version),
561561
public but un-released (use dotnetbuilds/public), or internal and unreleased (use dotnetbuilds/internal) -->
562562
<ItemGroup>
563-
<UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/$(DotNetRuntimeDownloadPath)" />
564-
<UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/$(DotNetRuntimeDownloadPath)" />
565-
<UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/$(DotNetRuntimeDownloadPath)"
563+
<UrisToDownload Include="https://builds.dotnet.microsoft.com/dotnet/$(DotNetRuntimeDownloadPath)" />
564+
<UrisToDownload Include="https://ci.dot.net/public/$(DotNetRuntimeDownloadPath)" />
565+
<UrisToDownload Include="https://ci.dot.net/internal/$(DotNetRuntimeDownloadPath)"
566566
Condition=" '$(DotnetRuntimeSourceFeedKey)' != '' ">
567567
<token>$(DotnetRuntimeSourceFeedKey)</token>
568568
</UrisToDownload>

src/Identity/Core/src/SignInManager.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,21 @@ public virtual async Task<bool> CanSignInAsync(TUser user)
162162
public virtual async Task RefreshSignInAsync(TUser user)
163163
{
164164
var auth = await Context.AuthenticateAsync(AuthenticationScheme);
165-
IList<Claim> claims = Array.Empty<Claim>();
165+
if (!auth.Succeeded || auth.Principal?.Identity?.IsAuthenticated != true)
166+
{
167+
Logger.LogError("RefreshSignInAsync prevented because the user is not currently authenticated. Use SignInAsync instead for initial sign in.");
168+
return;
169+
}
166170

171+
var authenticatedUserId = UserManager.GetUserId(auth.Principal);
172+
var newUserId = await UserManager.GetUserIdAsync(user);
173+
if (authenticatedUserId == null || authenticatedUserId != newUserId)
174+
{
175+
Logger.LogError("RefreshSignInAsync prevented because currently authenticated user has a different UserId. Use SignInAsync instead to change users.");
176+
return;
177+
}
178+
179+
IList<Claim> claims = Array.Empty<Claim>();
167180
var authenticationMethod = auth?.Principal?.FindFirst(ClaimTypes.AuthenticationMethod);
168181
var amr = auth?.Principal?.FindFirst("amr");
169182

src/Identity/test/Identity.Test/SignInManagerTest.cs

+66-14
Original file line numberDiff line numberDiff line change
@@ -592,38 +592,38 @@ public async Task CanExternalSignIn(bool isPersistent, bool supportsLockout)
592592
[InlineData(true, false)]
593593
[InlineData(false, true)]
594594
[InlineData(false, false)]
595-
public async Task CanResignIn(
596-
// Suppress warning that says theory methods should use all of their parameters.
597-
// See comments below about why this isn't used.
598-
#pragma warning disable xUnit1026
599-
bool isPersistent,
600-
#pragma warning restore xUnit1026
601-
bool externalLogin)
595+
public async Task CanResignIn(bool isPersistent, bool externalLogin)
602596
{
603597
// Setup
604598
var user = new PocoUser { UserName = "Foo" };
605599
var context = new DefaultHttpContext();
606600
var auth = MockAuth(context);
607601
var loginProvider = "loginprovider";
608-
var id = new ClaimsIdentity();
602+
var id = new ClaimsIdentity("authscheme");
609603
if (externalLogin)
610604
{
611605
id.AddClaim(new Claim(ClaimTypes.AuthenticationMethod, loginProvider));
612606
}
613-
// REVIEW: auth changes we lost the ability to mock is persistent
614-
//var properties = new AuthenticationProperties { IsPersistent = isPersistent };
615-
var authResult = AuthenticateResult.NoResult();
607+
608+
var claimsPrincipal = new ClaimsPrincipal(id);
609+
var properties = new AuthenticationProperties { IsPersistent = isPersistent };
610+
var authResult = AuthenticateResult.Success(new AuthenticationTicket(claimsPrincipal, properties, "authscheme"));
616611
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
617612
.Returns(Task.FromResult(authResult)).Verifiable();
618613
var manager = SetupUserManager(user);
614+
manager.Setup(m => m.GetUserId(claimsPrincipal)).Returns(user.Id.ToString());
619615
var signInManager = new Mock<SignInManager<PocoUser>>(manager.Object,
620616
new HttpContextAccessor { HttpContext = context },
621617
new Mock<IUserClaimsPrincipalFactory<PocoUser>>().Object,
622618
null, null, new Mock<IAuthenticationSchemeProvider>().Object, null)
623619
{ CallBase = true };
624-
//signInManager.Setup(s => s.SignInAsync(user, It.Is<AuthenticationProperties>(p => p.IsPersistent == isPersistent),
625-
//externalLogin? loginProvider : null)).Returns(Task.FromResult(0)).Verifiable();
626-
signInManager.Setup(s => s.SignInWithClaimsAsync(user, It.IsAny<AuthenticationProperties>(), It.IsAny<IEnumerable<Claim>>())).Returns(Task.FromResult(0)).Verifiable();
620+
621+
signInManager.Setup(s => s.SignInWithClaimsAsync(user,
622+
It.Is<AuthenticationProperties>(properties => properties.IsPersistent == isPersistent),
623+
It.Is<IEnumerable<Claim>>(claims => !externalLogin ||
624+
claims.Any(claim => claim.Type == ClaimTypes.AuthenticationMethod && claim.Value == loginProvider))))
625+
.Returns(Task.FromResult(0)).Verifiable();
626+
627627
signInManager.Object.Context = context;
628628

629629
// Act
@@ -634,6 +634,58 @@ public async Task CanResignIn(
634634
signInManager.Verify();
635635
}
636636

637+
[Fact]
638+
public async Task ResignInNoOpsAndLogsErrorIfNotAuthenticated()
639+
{
640+
var user = new PocoUser { UserName = "Foo" };
641+
var context = new DefaultHttpContext();
642+
var auth = MockAuth(context);
643+
var manager = SetupUserManager(user);
644+
var logger = new TestLogger<SignInManager<PocoUser>>();
645+
var signInManager = new Mock<SignInManager<PocoUser>>(manager.Object,
646+
new HttpContextAccessor { HttpContext = context },
647+
new Mock<IUserClaimsPrincipalFactory<PocoUser>>().Object,
648+
null, logger, new Mock<IAuthenticationSchemeProvider>().Object, null)
649+
{ CallBase = true };
650+
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
651+
.Returns(Task.FromResult(AuthenticateResult.NoResult())).Verifiable();
652+
653+
await signInManager.Object.RefreshSignInAsync(user);
654+
655+
Assert.Contains("RefreshSignInAsync prevented because the user is not currently authenticated. Use SignInAsync instead for initial sign in.", logger.LogMessages);
656+
auth.Verify();
657+
signInManager.Verify(s => s.SignInWithClaimsAsync(It.IsAny<PocoUser>(), It.IsAny<AuthenticationProperties>(), It.IsAny<IEnumerable<Claim>>()),
658+
Times.Never());
659+
}
660+
661+
[Fact]
662+
public async Task ResignInNoOpsAndLogsErrorIfAuthenticatedWithDifferentUser()
663+
{
664+
var user = new PocoUser { UserName = "Foo" };
665+
var context = new DefaultHttpContext();
666+
var auth = MockAuth(context);
667+
var manager = SetupUserManager(user);
668+
var logger = new TestLogger<SignInManager<PocoUser>>();
669+
var signInManager = new Mock<SignInManager<PocoUser>>(manager.Object,
670+
new HttpContextAccessor { HttpContext = context },
671+
new Mock<IUserClaimsPrincipalFactory<PocoUser>>().Object,
672+
null, logger, new Mock<IAuthenticationSchemeProvider>().Object, null)
673+
{ CallBase = true };
674+
var id = new ClaimsIdentity("authscheme");
675+
var claimsPrincipal = new ClaimsPrincipal(id);
676+
var authResult = AuthenticateResult.Success(new AuthenticationTicket(claimsPrincipal, new AuthenticationProperties(), "authscheme"));
677+
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
678+
.Returns(Task.FromResult(authResult)).Verifiable();
679+
manager.Setup(m => m.GetUserId(claimsPrincipal)).Returns("different");
680+
681+
await signInManager.Object.RefreshSignInAsync(user);
682+
683+
Assert.Contains("RefreshSignInAsync prevented because currently authenticated user has a different UserId. Use SignInAsync instead to change users.", logger.LogMessages);
684+
auth.Verify();
685+
signInManager.Verify(s => s.SignInWithClaimsAsync(It.IsAny<PocoUser>(), It.IsAny<AuthenticationProperties>(), It.IsAny<IEnumerable<Claim>>()),
686+
Times.Never());
687+
}
688+
637689
[Theory]
638690
[InlineData(true, true, true, true)]
639691
[InlineData(true, true, false, true)]

src/Installers/Windows/WindowsHostingBundle/Product.targets

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@
8383
-->
8484
<ItemGroup>
8585
<UrisToDownload Remove="@(UrisToDownload)" />
86-
<UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/Runtime/%(RemoteAsset.Identity)" />
87-
<UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/Runtime/%(RemoteAsset.Identity)" />
88-
<UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/Runtime/%(RemoteAsset.Identity)"
86+
<UrisToDownload Include="https://builds.dotnet.microsoft.com/dotnet/Runtime/%(RemoteAsset.Identity)" />
87+
<UrisToDownload Include="https://ci.dot.net/public/Runtime/%(RemoteAsset.Identity)" />
88+
<UrisToDownload Include="https://ci.dot.net/internal/Runtime/%(RemoteAsset.Identity)"
8989
Condition=" '$(DotnetRuntimeSourceFeedKey)' != '' ">
9090
<token>$(DotnetRuntimeSourceFeedKey)</token>
9191
</UrisToDownload>

0 commit comments

Comments
 (0)