Skip to content

Commit 4cb6793

Browse files
committed
Merge branch 'release/8.0'
2 parents 045afcd + f8cdb58 commit 4cb6793

File tree

10 files changed

+352
-279
lines changed

10 files changed

+352
-279
lines changed

eng/Version.Details.xml

Lines changed: 147 additions & 142 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

src/DataProtection/Abstractions/src/Resources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -118,15 +118,15 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="CryptCommon_PayloadInvalid" xml:space="preserve">
121-
<value>The payload was invalid.</value>
121+
<value>The payload was invalid. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
122122
</data>
123123
<data name="DataProtectionExtensions_NullPurposesCollection" xml:space="preserve">
124124
<value>The purposes collection cannot be null or empty and cannot contain null elements.</value>
125125
</data>
126126
<data name="CryptCommon_GenericError" xml:space="preserve">
127-
<value>An error occurred during a cryptographic operation.</value>
127+
<value>An error occurred during a cryptographic operation. Refer to the inner exception for more information.</value>
128128
</data>
129129
<data name="DataProtectionExtensions_NoService" xml:space="preserve">
130130
<value>No service for type '{0}' has been registered.</value>
131131
</data>
132-
</root>
132+
</root>

src/DataProtection/DataProtection/src/LoggingExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static bool IsLogLevelEnabledCore([NotNullWhen(true)] ILogger? logger, L
184184
[LoggerMessage(48, LogLevel.Error, "An error occurred while reading the key ring.", EventName = "ErrorOccurredWhileReadingKeyRing")]
185185
public static partial void ErrorOccurredWhileReadingKeyRing(this ILogger logger, Exception exception);
186186

187-
[LoggerMessage(49, LogLevel.Error, "The key ring does not contain a valid default key, and the key manager is configured with auto-generation of keys disabled.", EventName = "KeyRingDoesNotContainValidDefaultKey")]
187+
[LoggerMessage(49, LogLevel.Error, "The key ring does not contain a valid default protection key. The data protection system cannot create a new key because auto-generation of keys is disabled. For more information go to http://aka.ms/dataprotectionwarning", EventName = "KeyRingDoesNotContainValidDefaultKey")]
188188
public static partial void KeyRingDoesNotContainValidDefaultKey(this ILogger logger);
189189

190190
[LoggerMessage(50, LogLevel.Warning, "Using an in-memory repository. Keys will not be persisted to storage.", EventName = "UsingInMemoryRepository")]
@@ -235,6 +235,6 @@ private static bool IsLogLevelEnabledCore([NotNullWhen(true)] ILogger? logger, L
235235
[LoggerMessage(66, LogLevel.Information, "Key ring failed to load during application startup.", EventName = "KeyRingFailedToLoadOnStartup")]
236236
public static partial void KeyRingFailedToLoadOnStartup(this ILogger logger, Exception innerException);
237237

238-
[LoggerMessage(60, LogLevel.Warning, "Storing keys in a directory '{path}' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.", EventName = "UsingEphemeralFileSystemLocationInContainer")]
238+
[LoggerMessage(60, LogLevel.Warning, "Storing keys in a directory '{path}' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning", EventName = "UsingEphemeralFileSystemLocationInContainer")]
239239
public static partial void UsingEphemeralFileSystemLocationInContainer(this ILogger logger, string path);
240240
}

src/DataProtection/DataProtection/src/Resources.resx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -118,34 +118,34 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="CryptCommon_GenericError" xml:space="preserve">
121-
<value>An error occurred during a cryptographic operation. For more information go to http://aka.ms/dataprotectionwarning</value>
121+
<value>An error occurred during a cryptographic operation. Refer to the inner exception for more information.</value>
122122
</data>
123123
<data name="Common_BufferIncorrectlySized" xml:space="preserve">
124-
<value>The provided buffer is of length {0} byte(s). It must instead be exactly {1} byte(s) in length. For more information go to http://aka.ms/dataprotectionwarning</value>
124+
<value>The provided buffer is of length {0} byte(s). It must instead be exactly {1} byte(s) in length.</value>
125125
</data>
126126
<data name="CryptCommon_PayloadInvalid" xml:space="preserve">
127-
<value>The payload was invalid. For more information go to http://aka.ms/dataprotectionwarning</value>
127+
<value>The payload was invalid. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
128128
</data>
129129
<data name="Common_PropertyCannotBeNullOrEmpty" xml:space="preserve">
130130
<value>Property {0} cannot be null or empty.</value>
131131
</data>
132132
<data name="Common_DecryptionFailed" xml:space="preserve">
133-
<value>The provided payload could not be decrypted. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning</value>
133+
<value>The provided payload could not be decrypted. Refer to the inner exception for more information.</value>
134134
</data>
135135
<data name="Common_EncryptionFailed" xml:space="preserve">
136-
<value>An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning</value>
136+
<value>An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information.</value>
137137
</data>
138138
<data name="Common_KeyNotFound" xml:space="preserve">
139-
<value>The key {0:B} was not found in the key ring. For more information go to http://aka.ms/dataprotectionwarning</value>
139+
<value>The key {0:B} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
140140
</data>
141141
<data name="Common_KeyRevoked" xml:space="preserve">
142-
<value>The key {0:B} has been revoked. For more information go to http://aka.ms/dataprotectionwarning</value>
142+
<value>The key {0:B} has been revoked. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
143143
</data>
144144
<data name="ProtectionProvider_BadMagicHeader" xml:space="preserve">
145-
<value>The provided payload cannot be decrypted because it was not protected with this protection provider. For more information go to http://aka.ms/dataprotectionwarning</value>
145+
<value>The provided payload cannot be decrypted because it was not protected with this protection provider. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
146146
</data>
147147
<data name="ProtectionProvider_BadVersion" xml:space="preserve">
148-
<value>The provided payload cannot be decrypted because it was protected with a newer version of the protection provider. For more information go to http://aka.ms/dataprotectionwarning</value>
148+
<value>The provided payload cannot be decrypted because it was protected with a newer version of the protection provider.</value>
149149
</data>
150150
<data name="Common_ValueMustBeNonNegative" xml:space="preserve">
151151
<value>Value must be non-negative.</value>
@@ -154,42 +154,44 @@
154154
<value>The type '{1}' is not assignable to '{0}'.</value>
155155
</data>
156156
<data name="KeyManagementOptions_MinNewKeyLifetimeViolated" xml:space="preserve">
157-
<value>The new key lifetime must be at least one week. For more information go to http://aka.ms/dataprotectionwarning</value>
157+
<value>The new key lifetime must be at least one week. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
158158
</data>
159159
<data name="XmlKeyManager_DuplicateKey" xml:space="preserve">
160-
<value>The key {0:B} already exists in the keyring. For more information go to http://aka.ms/dataprotectionwarning</value>
160+
<value>The key {0:B} already exists in the keyring. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
161161
</data>
162162
<data name="Common_ArgumentCannotBeNullOrEmpty" xml:space="preserve">
163163
<value>Argument cannot be null or empty.</value>
164164
</data>
165165
<data name="Common_PropertyMustBeNonNegative" xml:space="preserve">
166-
<value>Property {0} must have a non-negative value. For more information go to http://aka.ms/dataprotectionwarning</value>
166+
<value>Property {0} must have a non-negative value.</value>
167167
</data>
168168
<data name="Platform_WindowsRequiredForGcm" xml:space="preserve">
169-
<value>GCM algorithms require the Windows platform. For more information go to http://aka.ms/dataprotectionwarning</value>
169+
<value>GCM algorithms require the Windows platform. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
170170
</data>
171171
<data name="CertificateXmlEncryptor_CertificateNotFound" xml:space="preserve">
172-
<value>A certificate with the thumbprint '{0}' could not be found. For more information go to http://aka.ms/dataprotectionwarning</value>
172+
<value>A certificate with the thumbprint '{0}' could not be found. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
173173
</data>
174+
<!-- This is no longer used -->
174175
<data name="EncryptedXmlDecryptor_DoesNotWorkOnCoreClr" xml:space="preserve">
175-
<value>Decrypting EncryptedXml-encapsulated payloads is not yet supported on Core CLR. For more information go to http://aka.ms/dataprotectionwarning</value>
176+
<value>Decrypting EncryptedXml-encapsulated payloads is not yet supported on Core CLR. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
176177
</data>
177178
<data name="AlgorithmAssert_BadBlockSize" xml:space="preserve">
178-
<value>The symmetric algorithm block size of {0} bits is invalid. The block size must be between 64 and 2048 bits, inclusive, and it must be a multiple of 8 bits. For more information go to http://aka.ms/dataprotectionwarning</value>
179+
<value>The symmetric algorithm block size of {0} bits is invalid. The block size must be between 64 and 2048 bits, inclusive, and it must be a multiple of 8 bits.</value>
179180
</data>
180181
<data name="AlgorithmAssert_BadDigestSize" xml:space="preserve">
181-
<value>The validation algorithm digest size of {0} bits is invalid. The digest size must be between 128 and 2048 bits, inclusive, and it must be a multiple of 8 bits. For more information go to http://aka.ms/dataprotectionwarning</value>
182+
<value>The validation algorithm digest size of {0} bits is invalid. The digest size must be between 128 and 2048 bits, inclusive, and it must be a multiple of 8 bits.</value>
182183
</data>
183184
<data name="AlgorithmAssert_BadKeySize" xml:space="preserve">
184-
<value>The symmetric algorithm key size of {0} bits is invalid. The key size must be between 128 and 2048 bits, inclusive, and it must be a multiple of 8 bits. For more information go to http://aka.ms/dataprotectionwarning</value>
185+
<value>The symmetric algorithm key size of {0} bits is invalid. The key size must be between 128 and 2048 bits, inclusive, and it must be a multiple of 8 bits.</value>
185186
</data>
186187
<data name="KeyRingProvider_NoDefaultKey_AutoGenerateDisabled" xml:space="preserve">
187-
<value>The key ring does not contain a valid default protection key. The data protection system cannot create a new key because auto-generation of keys is disabled. For more information go to http://aka.ms/dataprotectionwarning</value>
188+
<value>The key ring does not contain a valid default protection key. The data protection system cannot create a new key because auto-generation of keys is disabled. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
188189
</data>
189190
<data name="LifetimeMustNotBeNegative" xml:space="preserve">
190-
<value>{0} must not be negative. For more information go to http://aka.ms/dataprotectionwarning</value>
191+
<value>{0} must not be negative.</value>
191192
</data>
193+
<!-- This is only used to test LoggingExtensions.UsingEphemeralFileSystemLocationInContainer -->
192194
<data name="FileSystem_EphemeralKeysLocationInContainer" xml:space="preserve">
193-
<value>Storing keys in a directory '{path}' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to http://aka.ms/dataprotectionwarning</value>
195+
<value>Storing keys in a directory '{path}' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
194196
</data>
195197
</root>

src/DataProtection/Extensions/src/Resources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -118,12 +118,12 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="CryptCommon_GenericError" xml:space="preserve">
121-
<value>An error occurred during a cryptographic operation. For more information go to http://aka.ms/dataprotectionwarning</value>
121+
<value>An error occurred during a cryptographic operation. Refer to the inner exception for more information.</value>
122122
</data>
123123
<data name="TimeLimitedDataProtector_PayloadExpired" xml:space="preserve">
124-
<value>The payload expired at {0}. For more information go to http://aka.ms/dataprotectionwarning</value>
124+
<value>The payload expired at {0}.</value>
125125
</data>
126126
<data name="TimeLimitedDataProtector_PayloadInvalid" xml:space="preserve">
127-
<value>The payload is invalid. For more information go to http://aka.ms/dataprotectionwarning</value>
127+
<value>The payload is invalid. For more information go to https://aka.ms/aspnet/dataprotectionwarning</value>
128128
</data>
129129
</root>

src/Security/Authentication/test/JwtBearerTests.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Globalization;
45
using System.IdentityModel.Tokens.Jwt;
56
using System.Net;
67
using System.Net.Http;
@@ -958,15 +959,15 @@ public async Task ExpirationAndIssuedSetOnAuthenticateResult()
958959
}
959960

960961
[Fact]
961-
public async Task ExpirationAndIssuedNullWhenMinOrMaxValue()
962+
public async Task ExpirationAndIssuedWhenMinOrMaxValue()
962963
{
963964
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(new string('a', 128)));
964965
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
965966

966967
var claims = new[]
967968
{
968-
new Claim(ClaimTypes.NameIdentifier, "Bob")
969-
};
969+
new Claim(ClaimTypes.NameIdentifier, "Bob")
970+
};
970971

971972
var token = new JwtSecurityToken(
972973
issuer: "issuer.contoso.com",
@@ -995,8 +996,18 @@ public async Task ExpirationAndIssuedNullWhenMinOrMaxValue()
995996
Assert.Equal(HttpStatusCode.OK, response.Response.StatusCode);
996997
var responseBody = await response.Response.Content.ReadAsStringAsync();
997998
using var dom = JsonDocument.Parse(responseBody);
998-
Assert.Equal(JsonValueKind.Null, dom.RootElement.GetProperty("expires").ValueKind);
999999
Assert.Equal(JsonValueKind.Null, dom.RootElement.GetProperty("issued").ValueKind);
1000+
1001+
var expiresElement = dom.RootElement.GetProperty("expires");
1002+
Assert.Equal(JsonValueKind.String, expiresElement.ValueKind);
1003+
1004+
var elementValue = DateTime.Parse(expiresElement.GetString(), CultureInfo.InvariantCulture);
1005+
var elementValueUtc = elementValue.ToUniversalTime();
1006+
// roundtrip DateTime.MaxValue through parsing because it is lossy and we
1007+
// need equivalent values to compare against.
1008+
var max = DateTime.Parse(DateTime.MaxValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
1009+
1010+
Assert.Equal(max, elementValueUtc);
10001011
}
10011012

10021013
[Fact]

src/SignalR/server/Core/src/Internal/HubMethodDescriptor.cs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,53 @@ public HubMethodDescriptor(ObjectMethodExecutor methodExecutor, IServiceProvider
8181
}
8282
else if (p.CustomAttributes.Any())
8383
{
84+
var markedParameter = false;
8485
foreach (var attribute in p.GetCustomAttributes(true))
8586
{
8687
if (attribute is IFromServiceMetadata)
8788
{
88-
return MarkServiceParameter(index);
89+
ThrowIfMarked(markedParameter);
90+
markedParameter = true;
91+
MarkServiceParameter(index);
8992
}
9093
else if (attribute is FromKeyedServicesAttribute keyedServicesAttribute)
9194
{
92-
if (serviceProviderIsService is IServiceProviderIsKeyedService keyedServiceProvider &&
93-
keyedServiceProvider.IsKeyedService(GetServiceType(p.ParameterType), keyedServicesAttribute.Key))
95+
ThrowIfMarked(markedParameter);
96+
markedParameter = true;
97+
98+
if (serviceProviderIsService is IServiceProviderIsKeyedService keyedServiceProvider)
99+
{
100+
if (keyedServiceProvider.IsKeyedService(GetServiceType(p.ParameterType), keyedServicesAttribute.Key))
101+
{
102+
KeyedServiceKeys ??= new List<(int, object)>();
103+
KeyedServiceKeys.Add((index, keyedServicesAttribute.Key));
104+
MarkServiceParameter(index);
105+
}
106+
else
107+
{
108+
throw new InvalidOperationException($"'{p.ParameterType}' is not in DI as a keyed service.");
109+
}
110+
}
111+
else
94112
{
95-
KeyedServiceKeys ??= new List<(int, object)>();
96-
KeyedServiceKeys.Add((index, keyedServicesAttribute.Key));
97-
return MarkServiceParameter(index);
113+
throw new InvalidOperationException($"This service provider doesn't support keyed services.");
98114
}
99115
}
116+
117+
void ThrowIfMarked(bool marked)
118+
{
119+
if (marked)
120+
{
121+
throw new InvalidOperationException(
122+
$"{methodExecutor.MethodInfo.DeclaringType?.Name}.{methodExecutor.MethodInfo.Name}: The {nameof(FromKeyedServicesAttribute)} is not supported on parameters that are also annotated with {nameof(IFromServiceMetadata)}.");
123+
}
124+
}
125+
}
126+
127+
if (markedParameter)
128+
{
129+
// If the parameter is marked because of being a service, we don't want to consider it for method parameters during deserialization
130+
return false;
100131
}
101132
}
102133
else if (serviceProviderIsService?.IsService(GetServiceType(p.ParameterType)) == true)

0 commit comments

Comments
 (0)