4

This is my first time to work with Docker and AD.

I am implementing a spring boot application that uses Active directory for authorization.

I have gone through LDAP tutorial https://spring.io/guides/gs/authenticating-ldap/

I have downloaded a docker image of Active Directory.

https://hub.docker.com/r/pitkley/samba-ad-dc/#environment-variables

Now i want to use this docker image for authorization in my local machine.

Docker image is running,

$ docker run -i -t 041144877f9f /bin/bash root@3c01c419c248:/#

How i can use this image in my spring boot app for authorization?
What should i expect from this docker image?

I use mac, java, spring boot. Below is my code,

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .anyRequest()
                .fullyAuthenticated()
                    .and()
                .formLogin();
    }

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth
        .ldapAuthentication()
            .userDnPatterns("uid={0},ou=people")
            .groupSearchBase("ou=groups")
            .contextSource(contextSource())
            .passwordCompare()
                .passwordEncoder(new LdapShaPasswordEncoder())
                .passwordAttribute("userPassword");
    }

    @Bean
    public DefaultSpringSecurityContextSource contextSource() {
        return  new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"), "dc=springframework,dc=org");
    }
}
scott
  • 43
  • 1
  • 7

0 Answers0