-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Populate the ValidIssuer and the ValidAudience properties of the JwtBearerOptions.TokenValidationParameters. #52821
Conversation
…nValidationParameters.
Thanks for your PR, @satma0745. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Ideally this PR should include 1 or more tests that validate the fix and that it doesn't get broken again in the future by accident. |
@dotnet-policy-service agree |
@martincostello, I've refactored old tests a bit and provide my own one. Now we have 3 tests related to reading TokenValidationParameters from configuration:
|
I tried sticking with the established convention of testing and designed the tests not to stand out too much. |
/azp run |
Commenter does not have sufficient privileges for PR 52821 in repo dotnet/aspnetcore |
|
But what's about the Assigned Developer? Won't he be un-assigned when I close the PR? |
Not to my knowledge. |
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.
@captainsafia Can you take a look at this since you worked on this and very clearly intentionally set just the multi-value properties?
I noticed while exploring the identity model code that even though they expose single-value properties for config (e.g.
ValidIssuer
andValidAudience
) it looks like the multi-value properties are ultimately used as the source of truth. Updated this to just set the multi-value property.
I think the current behavior of not setting the single-value properties is fine since it gets included in the multi-value property. And based on my reading of the ValidateIssuerAsync method in IdentityModel, this change is redundant since it checks against ValidIssuer
and then all the ValidIssuers
.
If we decide to change the config binding at all, we should make it align with the TokenValidationParameters
more directly and not include the single-value property in the multi-value property. That might make things less confusing, and I don't think it would cause any real problems since it appears IdentityModel looks at both together.
@@ -1017,8 +1017,7 @@ public void CanReadJwtBearerOptionsFromConfig() | |||
var config = new ConfigurationBuilder().AddInMemoryCollection(new[] | |||
{ | |||
new KeyValuePair<string, string>("Authentication:Schemes:Bearer:ValidIssuer", "dotnet-user-jwts"), | |||
new KeyValuePair<string, string>("Authentication:Schemes:Bearer:ValidAudiences:0", "http://localhost:5000"), | |||
new KeyValuePair<string, string>("Authentication:Schemes:Bearer:ValidAudiences:1", "https://localhost:5001"), | |||
new KeyValuePair<string, string>("Authentication:Schemes:Bearer:ValidAudience", "http://localhost:5000"), |
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.
Can we include a test that configures both ValidIssuer
and ValidIssuers
? Or ValidAudience
and ValidAudiences
?
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 talked to @captainsafia, and we're fine taking this change since we have quite a few previews left to see if there are any problems with this simplification.
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
PR for the Issue #52820.