-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extensibility tests: Issuer signing key - JWT, SAML and SAML2 (#3029)
* Added failure type and log message for the case where the issuer signing key validator throws an exception * Added IssuerSigningKeyValidationError and updated its use within the signing key validation * Removed optionality from the CallContext in the issuer signing key validation delegate, updated the test skip validation delegates (cherry picked from commit a4476e1) * Added custom validation delegates and validation errors for issuer signing key extensibility testing (cherry picked from commit ad1e0bd) * Handle the case where the issuer signing key validator throws an exception (cherry picked from commit f7b0db7) * Added extensibility tests for issuer signing key validation (cherry picked from commit e432f8c) * Updated validation failure type position in tests * Apply suggestions from code review Co-authored-by: jennyf19 <[email protected]> * Added missing SecurityKey to the legacy implementation of ValidateIssuerSigningKey --------- Co-authored-by: jennyf19 <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,198 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...rosoft.IdentityModel.Tokens/Validation/Results/Details/IssuerSigningKeyValidationError.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Diagnostics; | ||
using System; | ||
|
||
#nullable enable | ||
namespace Microsoft.IdentityModel.Tokens | ||
{ | ||
internal class IssuerSigningKeyValidationError : ValidationError | ||
{ | ||
internal IssuerSigningKeyValidationError( | ||
MessageDetail messageDetail, | ||
ValidationFailureType validationFailureType, | ||
Type exceptionType, | ||
StackFrame stackFrame, | ||
SecurityKey? invalidSigningKey, | ||
Exception? innerException = null) | ||
: base(messageDetail, validationFailureType, exceptionType, stackFrame, innerException) | ||
{ | ||
InvalidSigningKey = invalidSigningKey; | ||
} | ||
|
||
internal override Exception GetException() | ||
{ | ||
if (ExceptionType == typeof(SecurityTokenInvalidSigningKeyException)) | ||
{ | ||
SecurityTokenInvalidSigningKeyException? exception = new(MessageDetail.Message, InnerException) | ||
{ | ||
SigningKey = InvalidSigningKey | ||
}; | ||
exception.SetValidationError(this); | ||
|
||
return exception; | ||
} | ||
|
||
return base.GetException(); | ||
} | ||
|
||
internal static new IssuerSigningKeyValidationError NullParameter(string parameterName, StackFrame stackFrame) => new( | ||
MessageDetail.NullParameter(parameterName), | ||
ValidationFailureType.NullArgument, | ||
typeof(SecurityTokenArgumentNullException), | ||
stackFrame, | ||
null); // InvalidSigningKey | ||
|
||
protected SecurityKey? InvalidSigningKey { get; } | ||
} | ||
} | ||
#nullable restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.