Skip to content

XML configuration with multiple security:http register multiple requestDataValueProcessorΒ #6423

Closed

Description

@mtraut

Summary

We use multiple XML configuration for different realms. If CSRF is not disabled, the application startup fails beause of multiple registrations of requestDataValueProcessor bean.

Actual Behavior

see org.springframework.security.config.http.CsrfBeanDefinitionParser.parse()


		boolean webmvcPresent = ClassUtils.isPresent(DISPATCHER_SERVLET_CLASS_NAME,
				getClass().getClassLoader());
		if (webmvcPresent) {
			RootBeanDefinition beanDefinition = new RootBeanDefinition(
					CsrfRequestDataValueProcessor.class);
			BeanComponentDefinition componentDefinition = new BeanComponentDefinition(
					beanDefinition, REQUEST_DATA_VALUE_PROCESSOR);
			pc.registerBeanComponent(componentDefinition);
		}

unconditionally registers bean

Expected Behavior

CsrfBeanDefinitionParser should check presence?

Version

version 5.1.3

Sample

This will not start

	<bean id="errorAuthenticationEntryPoint"
		class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint" />
 	<security:http name="securityRealmControl" pattern="/api/v1/control/**" entry-point-ref="errorAuthenticationEntryPoint">
		<security:intercept-url pattern="/**" access="hasRole('OPERATOR')" />
	</security:http>
 	<security:http name="securityRealmFlow" pattern="/api/v1/flow/**" entry-point-ref="errorAuthenticationEntryPoint">
		<security:intercept-url pattern="/api/v1/flow/*/create" access="hasRole('USER')" />
	</security:http>

Activity

  1. rwinch commented on Jan 14, 2019

    @rwinch
    Member

    Thank you for the report. Can you please provide a minimal and complete sample to reproduce the problem?

  2. mtraut commented on Jan 15, 2019

    @mtraut
    Author

    Here you are....

  3. rwinch commented on Jan 16, 2019

    @rwinch
    Member

    You are right that the CsrfBeanDefinitionParser should only register a new requestDataValueProcessor if it is not already found. Would you be interested in submitting a Pull Request?

    You can work around this by providing the following setting spring.main.allow-bean-definition-overriding=true which is the default for non Spring Boot applications.

  4. added this to the 5.2.x milestone on Jan 16, 2019
  5. added
    status: ideal-for-contributionAn issue that we actively are looking for someone to help us with
    and removed on Jan 16, 2019
  6. ankurpathak commented on Jan 17, 2019

    @ankurpathak
    Contributor

    Pull request for issue:
    #6451

  7. ankurpathak commented on Jan 17, 2019

    @ankurpathak
    Contributor

    @rwinch @mtraut its working with sample.

  8. mtraut commented on Jan 17, 2019

    @mtraut
    Author

    thx for helping. I've never created a pull request before.

  9. 2 remaining items

  10. added a commit that references this issue on Jan 18, 2019
    4376342
  11. modified the milestones: 5.2.x, 5.2.0.M2 on Jan 22, 2019
  12. self-assigned this
    on Jan 22, 2019
  13. added 5 commits that reference this issue on Jan 22, 2019
    2e70d66
    0aaaaf9
    64ec35c
    41a7d82
    da17016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions