Browse Source
Update ValidateDataProtectionToken to support IDataProtectionProvider implementations that don't use the default magic header
pull/1824/head
sbolofsson
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
39 additions and
9 deletions
-
src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs
-
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs
-
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs
|
|
|
@ -62,9 +62,19 @@ public static partial class OpenIddictClientDataProtectionHandlers |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
// Note: ASP.NET Core Data Protection tokens always start with "CfDJ8", that corresponds
|
|
|
|
// to the base64 representation of the magic "09 F0 C9 F0" header identifying DP payloads.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal)) |
|
|
|
// Note: ASP.NET Core Data Protection tokens created by the default implementation always start
|
|
|
|
// with "CfDJ8", that corresponds to the base64 representation of the "09 F0 C9 F0" value used
|
|
|
|
// by KeyRingBasedDataProtectionProvider as a Data Protection version identifier/magic header.
|
|
|
|
//
|
|
|
|
// Unless a custom provider implementation - that may use a different mechanism - has been
|
|
|
|
// registered, return immediately if the token doesn't start with the expected magic header.
|
|
|
|
//
|
|
|
|
// See https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/authenticated-encryption-details
|
|
|
|
// for more information.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal) && |
|
|
|
string.Equals(_options.CurrentValue.DataProtectionProvider.GetType().FullName, |
|
|
|
"Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtectionProvider", |
|
|
|
StringComparison.Ordinal)) |
|
|
|
{ |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
@ -62,9 +62,19 @@ public static partial class OpenIddictServerDataProtectionHandlers |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
// Note: ASP.NET Core Data Protection tokens always start with "CfDJ8", that corresponds
|
|
|
|
// to the base64 representation of the magic "09 F0 C9 F0" header identifying DP payloads.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal)) |
|
|
|
// Note: ASP.NET Core Data Protection tokens created by the default implementation always start
|
|
|
|
// with "CfDJ8", that corresponds to the base64 representation of the "09 F0 C9 F0" value used
|
|
|
|
// by KeyRingBasedDataProtectionProvider as a Data Protection version identifier/magic header.
|
|
|
|
//
|
|
|
|
// Unless a custom provider implementation - that may use a different mechanism - has been
|
|
|
|
// registered, return immediately if the token doesn't start with the expected magic header.
|
|
|
|
//
|
|
|
|
// See https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/authenticated-encryption-details
|
|
|
|
// for more information.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal) && |
|
|
|
string.Equals(_options.CurrentValue.DataProtectionProvider.GetType().FullName, |
|
|
|
"Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtectionProvider", |
|
|
|
StringComparison.Ordinal)) |
|
|
|
{ |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
@ -57,9 +57,19 @@ public static partial class OpenIddictValidationDataProtectionHandlers |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
// Note: ASP.NET Core Data Protection tokens always start with "CfDJ8", that corresponds
|
|
|
|
// to the base64 representation of the magic "09 F0 C9 F0" header identifying DP payloads.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal)) |
|
|
|
// Note: ASP.NET Core Data Protection tokens created by the default implementation always start
|
|
|
|
// with "CfDJ8", that corresponds to the base64 representation of the "09 F0 C9 F0" value used
|
|
|
|
// by KeyRingBasedDataProtectionProvider as a Data Protection version identifier/magic header.
|
|
|
|
//
|
|
|
|
// Unless a custom provider implementation - that may use a different mechanism - has been
|
|
|
|
// registered, return immediately if the token doesn't start with the expected magic header.
|
|
|
|
//
|
|
|
|
// See https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/authenticated-encryption-details
|
|
|
|
// for more information.
|
|
|
|
if (!context.Token.StartsWith("CfDJ8", StringComparison.Ordinal) && |
|
|
|
string.Equals(_options.CurrentValue.DataProtectionProvider.GetType().FullName, |
|
|
|
"Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtectionProvider", |
|
|
|
StringComparison.Ordinal)) |
|
|
|
{ |
|
|
|
return default; |
|
|
|
} |
|
|
|
|