spring-projects / spring-projects/spring-security

SEC-2482: ldapAuthentication().withObjectPostProcessor(...) can't change order of post processors

Open
#2,703 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: config type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Bruce Brouwer (Migrated from SEC-2482) said:

I am trying to use DefaultTlsDirContextAuthenticationStrategy() in an ObjectPostProcessor to make all my connections to LDAP secured. That part seems to work, however in my environment, that means I need to turn off pooling. I have tried in the ObjectPostProcessor to simply call contextSource.setPooled(false), but this ObjectPostProcessor is called too late because .afterPropertiesSet(), which configures the environment based on the pooled property is called by AutowireBeanFactoryObjectPostProcessor before my post processor ever gets a chance to call .setPooled(false).

Is there a way to make it so my post processors go before any of the default Spring post processors? Should mine always go before Spring's post processors? Or do we need something new, like a pre-processor?

public class SecureLdapContextSourcePostProcessor implements ObjectPostProcessor<LdapContextSource> {
    @Override
    public <O extends LdapContextSource> O postProcess(final O contextSource) {
        contextSource.setPooled(false);
        contextSource.setAuthenticationStrategy(new DefaultTlsDirContextAuthenticationStrategy());
        return contextSource;
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ldapAuthentication().withObjectPostProcessor(...) and the AutowireBeanFactoryObjectPostProcessor mentioned in the report. Trace the post-processor ordering and determine how a custom processor could run before the default processing; done means setPooled(false) and the TLS authentication strategy take effect in the requested order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, backend, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.