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

relying-party-registration doesn't resolve placeholders in xml #16308

Open
rvervaek opened this issue Dec 19, 2024 · 3 comments
Open

relying-party-registration doesn't resolve placeholders in xml #16308

rvervaek opened this issue Dec 19, 2024 · 3 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug

Comments

@rvervaek
Copy link

Describe the bug
When declaring a relying-party-registration element in a Spring Security XML namespace configuration, attributes having a property-placeholder value (e.g. ${...}) are not resolved, even when property-placeholder configuration is declared.

Expected behavior
The property-placeholders are resolved when the Spring context is created (ref. #14645).

Sample
demo.zip

Versions:

  • Spring framework: 6.2.1
  • Spring Security 6.4.2
@rvervaek rvervaek added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Dec 19, 2024
@kse-music
Copy link
Contributor

It seems that the settings.properties was not added to the environment. I can start it using the method below.

public class DemoApplication {

	public static void main(String[] args) throws IOException {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"ac-security-config.xml"},false);
		context.getEnvironment().getPropertySources()
				.addLast(new ResourcePropertySource(new ClassPathResource("settings.properties")));
		context.refresh();
		context.start();
	}

}

@rvervaek
Copy link
Author

@kse-music

The Spring Framework documentation mentions that adding PropertySources to the Environment is only required in case of modularization of properties. In this example this is not the case is it?

@kse-music
Copy link
Contributor

@rvervaek

By researching the PropertySourcesPlaceholderConfigurer source code, it does not actually add properties directly to the Environment. Instead, after the instance is created, it invkoe the postProcessBeanFactory method, where it adds the property source and the current Environment as two property sources and calls addEmbeddedValueResolver to add it to the IOC container as a placeholder resolver. Therefore, when parsing and loading BeanDefinition during XML parsing, there are only two property sources in Environment: systemEnvironment and systemProperties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants