Benson Wally Tran
Benson Wally Tran

Reputation: 339

Dynamically Configure LDAP Server using Spring Security

The Spring Security Tutorial has an example of configuring an LDAP Server:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .anyRequest().fullyAuthenticated()
                .and()
            .formLogin();
    }
    @Configuration
    protected static class AuthenticationConfiguration extends
            GlobalAuthenticationConfigurerAdapter {

        @Override
        public void init(AuthenticationManagerBuilder auth) throws Exception {
            auth
                .ldapAuthentication()
                .userDnPatterns("uid={0},ou=people")
                .groupSearchBase("ou=groups")
                .contextSource().ldif("classpath:test-server.ldif");
        }
    }
}

However, I'm looking for a way to initialize the the LDAP server dynamically, not in the configuration file. I can't seem to find any examples. The purpose of this is to implement SSO for a login form.

Upvotes: 1

Views: 1086

Answers (1)

Benson Wally Tran
Benson Wally Tran

Reputation: 339

I found it easier to work with a lower-level directory, ldaptive, to solve this problem.

Upvotes: 1

Related Questions