Skip to content
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

Avoid UriComponentsBuilder.fromUri #15853

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bodograumann
Copy link

Closes #15852

By using UriComponentsBuilder.fromUriString we stay in a single semantic context and do not loose information.

@pivotal-cla
Copy link

@bodograumann Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2024
@pivotal-cla
Copy link

@bodograumann Thank you for signing the Contributor License Agreement!

Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @bodograumann! WIll you please also add a test for both servlet and reactive that show that this behavior is now repaired?

@jzheaux jzheaux self-assigned this Sep 26, 2024
@jzheaux jzheaux added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 26, 2024
@jzheaux
Copy link
Contributor

jzheaux commented Sep 26, 2024

Thinking about this more, while it may still be valuable for this PR to have these tests, it seems to me that @rstoyanchev is open to updating UriComponentsBuilder. I think it would be better to focus on addressing the issue in Framework first. Have you already considered submitting a PR there?

@bodograumann
Copy link
Author

True, fixing the underlying issue in UriComponentsBuilder would be preferrable, but I focused on what I could get done in limited time.
I'll try to look into adding a test, which will require somehow mocking the RestTemplate and maybe I'll also find time to understand the difference between authority and host enough to propose a solution for UriComponentsBuilder.

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Sep 27, 2024

The challenge with re-parsing the authority is having to extract the parsing logic out of the whole algorithm. Couldn't you re-parse the full URI string in fallback mode? Something like:

URI uri = URI.create(issuer);
if (uri.getHost() == null && getAuthority() != null) {
    uri = UriComponentsBuilder.fromUriString(issuer).build().toURI();
}

This would impact only such URI's, and minimize any potential disruption for all others.

@bodograumann
Copy link
Author

That makes sense @rstoyanchev .
Also I couldn't find a way to mock the RestTemplate here, so I create a PR for the spring framework: spring-projects/spring-framework#33614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JwtDecoderProviderConfigurationUtils incorrectly handles issuer URI
5 participants