-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added internal virtual on TokenHandler #3084
base: dev
Are you sure you want to change the base?
Conversation
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
Add AadIssuer with ValidationParameters Added tests to AadIssuerValidator for ValidationParameters
b69fd68
to
75acd6c
Compare
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've asked a few questions.
A lot of duplicated code in AadTokenValidationParametersExtension / AadValidationParametersExtension.Internal
@@ -374,7 +380,9 @@ public string NameClaimType | |||
/// Gets or sets the <see cref="IDictionary{TKey, TValue}"/> that contains a collection of custom key/value pairs. | |||
/// This allows addition of parameters that could be used in custom token validation scenarios. | |||
/// </summary> | |||
public IDictionary<string, object> PropertyBag { get; } | |||
public IDictionary<string, object> PropertyBag => _propertyBag ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this one is not unique to the instance? is it shared between ValidationParameters that were cloned from each other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes shared between all instances.
@@ -19,7 +19,7 @@ namespace Microsoft.IdentityModel.Validators | |||
/// <summary> | |||
/// Generic class that validates the issuer for either JsonWebTokens or JwtSecurityTokens issued from the Microsoft identity platform (AAD). | |||
/// </summary> | |||
public class AadIssuerValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much copy/paste is there in the partial implementation vs how much can we have in common? I understand that the input (ValidationParameters, context) will be different, and that the output is an Error, not an exception thrown, but can the logic be a bit more common?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly, that can be done. Not the goal right now. The goal is to enable upper layers to make the calls.
src/Microsoft.IdentityModel.Validators/AadValidationParametersExtension.Internal.cs
Show resolved
Hide resolved
/// <param name="securityToken">The <see cref="SecurityToken"/> being validated, could be a JwtSecurityToken or JsonWebToken.</param> | ||
/// <param name="configuration">The <see cref="BaseConfiguration"/> provided.</param> | ||
/// <returns><c>true</c> if the issuer of the signing key is valid; otherwise, <c>false</c>.</returns> | ||
internal static bool ValidateIssuerSigningKey(SecurityKey securityKey, SecurityToken securityToken, BaseConfiguration configuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is common with AadTokenValidationParametersExtensions (to the letter)
|
||
if (!string.Equals(signingKeyCloudInstanceName, configurationCloudInstanceName, StringComparison.Ordinal)) | ||
throw LogHelper.LogExceptionMessage( | ||
new SecurityTokenInvalidCloudInstanceException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only line that changes in this method vs in AadValidationParametersExtension
} | ||
} | ||
|
||
private static JsonWebKey GetJsonWebKeyBySecurityKey(OpenIdConnectConfiguration configuration, SecurityKey securityKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same method and content in both
return null; | ||
} | ||
|
||
private static string GetTid(SecurityToken securityToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same method and content in both
} | ||
} | ||
|
||
private static void EnforceSingleClaimCaseInsensitive(IEnumerable<string> keys, string claimType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same method and content in both
Add support to AadIssuerValidator for ValidationParameters.
Removed the parameter BaseConfiguration from delegates as ValidationParameters has ConfigurationManager which should be used to obtain BaseConfiguration when needed.
ValidationParameters.PropertyBag was not instantiated.
Create ValidationParameters.PropertyBag and InstancePropertyBag on demand.
Copy logic from existing AadIssuerValidator, keeping as code the same as much as possible.
Copy logic from existing AadTokenValidationParametersExtension to AadValidationParametersExtension keeping as code the same as much as possible.
This copied code will need to be refactored into common base code.
Move CloudInstanceNameKey to constants file.
Added tests to AadTokenValidationParametersExtensionTests and MicrosoftIdentityIssuerValidatorTest that cover existing tests.