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

SEC-2919: DefaultLoginGeneratingFilter incorrectly used if login-url="/login" #3132

spring-projects-issues opened this issue Mar 25, 2015 · 0 comments
in: config type: bug type: jira


Copy link

spring-projects-issues commented Mar 25, 2015

Rob Winch (Migrated from SEC-2919) said:

If an application specifies form-login@login-url="/login" then the DefaultLoginGeneratingFilter is incorrectly used. This means that the custom login page cannot be specified with the URL "/login". For example:

<http ...>
    <form-login login-page="/login" ... />

h1. Workaround

h2. Using a different URL

One workaround is to use a different URL for the login page. For example, one could use "/authenticate".

h2. Using a BeanDefinitionRegistryPostProcessor

Alternatively, the following BeanDefinitionRegistryPostProcessor will fix the issue by removing the DefaultLoginPageGeneratingFilter. To use it simply ensure to register the BeanDefinitionRegistryPostProcessor as a Bean.

import java.util.Iterator;
import java.util.List;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class Sec2919PostProcessor implements BeanDefinitionRegistryPostProcessor {
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
            throws BeansException {
        String[] beanDefinitionNames = registry.getBeanDefinitionNames();
        for(String name : beanDefinitionNames) {
            BeanDefinition beanDefinition = registry.getBeanDefinition(name);
            if(beanDefinition.getBeanClassName().equals(DefaultSecurityFilterChain.class.getName())) {
                List<Object> filters = (List<Object>) beanDefinition.getConstructorArgumentValues().getArgumentValue(1, List.class).getValue();
                Iterator<Object> iFilters = filters.iterator();
                while(iFilters.hasNext()) {
                    Object f =;
                    if(f instanceof BeanDefinition) {
                        BeanDefinition bean = (BeanDefinition) f;
                        if(bean.getBeanClassName().equals(DefaultLoginPageGeneratingFilter.class.getName())) {

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
            throws BeansException {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: config type: bug type: jira
None yet

No branches or pull requests

2 participants