Skip to content

Conflict between xml <security:http> and Java SecurityFilterChain declaration configurations #11108

@KWSimon

Description

@KWSimon

Summary

I posted this question on StackOverflow : https://stackoverflow.com/questions/71871306/spring-security-how-to-mix-xml-securityhttp-and-java-securityfilterchain-de

When mixing xml configuration and Java configuration, if a <security:http> element exists in the xml configuration file the SecurityFilterChain created in the Java configuration is not used. The method creating the bean is called but it is not present in the FilterChainProxy when requests are processed.

Actual Behavior

By using this sample it is possible to reproduce the issue :
https://github.com/KWSimon/minoshill/tree/main/SpringSecurityIssue

  • Run the application :
    mvn clean package tomee:run

This resource shouldn't be reachable because it is protected by the SecurityFilterChain declared in the testapp.SecurityConfiguration class :
http://localhost:8180/testapp/secured/secured.html

  • Stop the application

  • Comment or remove the following element from the SpringConfig.xml file : <security:http pattern="/page/**" security="none"/>

  • Run the application :
    mvn clean package tomee:run

The following resource is now protected by the filter :
http://localhost:8180/testapp/secured/secured.html

Expected Behavior

Both xml and Java configuration should allow to declare and add filters to the SecurityFilterChain.

Configuration

Version

Spring Security 5.6.2

Sample

By using this sample it is possible to reproduce the issue :
https://github.com/KWSimon/minoshill/tree/main/SpringSecurityIssue

Metadata

Metadata

Assignees

Labels

for: stackoverflowA question that's better suited to stackoverflow.com

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions