Skip to content

Fetch configuration when validating SAML issuer and signature#2412

Merged
brentschmaltz merged 8 commits into
AzureAD:devfrom
Hakon:saml-configuration-fetch
Mar 13, 2024
Merged

Fetch configuration when validating SAML issuer and signature#2412
brentschmaltz merged 8 commits into
AzureAD:devfrom
Hakon:saml-configuration-fetch

Conversation

@Hakon

@Hakon Hakon commented Nov 21, 2023

Copy link
Copy Markdown

Fetch configuration when validating SAML issuer and signature

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • If any gains or losses in performance are possible, you've included benchmarks for your changes. More info
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Fetch configuration on token validation for SAML in the same way as JwtSecurityTokenHandler

Description

This is already done in the JwtSecurityTokenHandler and the semantics should be similar.
This caused a regression in Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler which assumes the token handler will fetch the current configuration as part of the token validation if the ConfigurationManager is a subclass of BaseConfigurationManager.
This change makes the SamlSecurityTokenHandler and Saml2SecurityTokenHandler semantics equal to the JwtSecurityTokenHandler with regards to fetching the configuration before validation.

This discrepancy allowed the following bug to appear in Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler.

Fixes #2406

This is already done in the JwtSecurityTokenHandler and the semantics should be similar.
This caused a regression in Microsoft.AspNetCore.Authentication.WsFederation.WsFederationHandler which assumes the token handler will fetch the current configuration as part of the token validation if the ConfigurationManager is a subclass of BaseConfigurationManager.
This change makes the SamlSecurityTokenHandler and Saml2SecurityTokenHandler equal to the JwtSecurityTokenHandler with regards to fetching the configuration before validation.
Comment thread src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs Outdated
Comment thread src/Microsoft.IdentityModel.Tokens.Saml/Saml/SamlSecurityTokenHandler.cs Outdated
@Hakon

Hakon commented Nov 22, 2023

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Frende"

hakon.lerring added 2 commits November 22, 2023 07:25
Refactor PopulateValidationParametersWithCurrentConfigurationAsync null check to guard with an early return.
Rename cloned variable to make code easier to read.
Refactor PopulateValidationParametersWithCurrentConfigurationAsync null check to guard with an early return.
Rename cloned variable to make code easier to read.
@Hakon Hakon marked this pull request as ready for review November 22, 2023 12:58
@Hakon

Hakon commented Nov 23, 2023

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Frende"

@Hakon

Hakon commented Nov 28, 2023

Copy link
Copy Markdown
Author

Do you need anything more from me on this issue?

Comment thread src/Microsoft.IdentityModel.Tokens.Saml/Saml2/Saml2SecurityTokenHandler.cs Outdated
@jennyf19

Copy link
Copy Markdown
Contributor

@Hakon will you be continuing work on this PR? Please see above comments from @brentschmaltz thank you.

@Hakon

Hakon commented Jan 29, 2024

Copy link
Copy Markdown
Author

I will, it's just a bit busy period for me. If someone else want to continue this work I'm open to share :)

hakon.lerring added 2 commits February 26, 2024 08:41
Issuer set,
Key set,
Issuer and key set
and nothing set
@Hakon Hakon requested a review from brentschmaltz February 26, 2024 08:32
@Hakon

Hakon commented Feb 28, 2024

Copy link
Copy Markdown
Author

I implemented the changes mentioned, could you take another look?

@brentschmaltz brentschmaltz merged commit 795bbf0 into AzureAD:dev Mar 13, 2024
@Hakon Hakon deleted the saml-configuration-fetch branch March 18, 2024 14:37
@DominikAmon

Copy link
Copy Markdown

Update other Microsoft packages to latest as well, such as: Microsoft.AspNetCore.Authentication.WsFederation
The latest package 8.0.3 and even the 9.x.x Preview sill references the old 7.1.2 version.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SamlSecurityTokenHandler and Saml2SecurityTokenHandler does not fetch configuration from ConfigurationManager on ValidateTokenAsync

4 participants