title: Spring security + spring social without xml
body: <p>I'm trying to create a login interface only with a Facebook login. And I would like that once logged in the user stay logged and disconnect if he wants. </p>
  
  <p>I don't want the user to register via login/pass, only facebook so once he's logged I only keep information facebook gave me(mail,name etc.).</p>
  
  <p>I followed the tutorial here : <a href="http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#jc-form" rel="nofollow">http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#jc-form</a></p>
  
  <p>And tried to figure it out with this : <a href="https://github.com/spring-projects/spring-social-samples/blob/master/spring-social-showcase-boot/src/main/java/org/springframework/social/showcase/config/SecurityConfig.java" rel="nofollow">https://github.com/spring-projects/spring-social-samples/blob/master/spring-social-showcase-boot/src/main/java/org/springframework/social/showcase/config/SecurityConfig.java</a></p>
  
  <p>But I can't make it work, it always say : </p>
  
  <blockquote>
    <p>org.springframework.security.ldap.DefaultSpringSecurityContextSource
    not found</p>
  </blockquote>
  
  <p>i use maven and not graddle, here is my pom.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  &lt;artifactId&gt;cinemagik&lt;/artifactId&gt;
  &lt;version&gt;0.1.0&lt;/version&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.1.8.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit-dep&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.sitebricks&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j&lt;/artifactId&gt;
          &lt;version&gt;0.8.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;version&gt;1.0.13&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.3-1102-jdbc41&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.mongodb&lt;/groupId&gt;
          &lt;artifactId&gt;mongo-java-driver&lt;/artifactId&gt;
          &lt;version&gt;2.13.0-rc0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
          &lt;version&gt;2.5.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;org.eclipse.persistence.jpa.modelgen.processor&lt;/artifactId&gt;
          &lt;version&gt;2.5.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;nz.net.ultraq.thymeleaf&lt;/groupId&gt;
          &lt;artifactId&gt;thymeleaf-layout-dialect&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.social&lt;/groupId&gt;
          &lt;artifactId&gt;spring-social-facebook&lt;/artifactId&gt;
          &lt;version&gt;1.1.1.RELEASE&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.social&lt;/groupId&gt;
          &lt;artifactId&gt;spring-social-twitter&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
          &lt;version&gt;4.0.0.M2&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;4.0.0.M2&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.social&lt;/groupId&gt;
          &lt;artifactId&gt;spring-social-security&lt;/artifactId&gt;
          &lt;version&gt;1.1.0.RELEASE&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.ldap&lt;/groupId&gt;
          &lt;artifactId&gt;spring-ldap-core&lt;/artifactId&gt;
          &lt;version&gt;1.3.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;properties&gt;
      &lt;start-class&gt;app.Application&lt;/start-class&gt;
  &lt;/properties&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-milestone&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/libs-release&lt;/url&gt;
      &lt;/repository&gt;
      &lt;repository&gt;
          &lt;id&gt;unknown-jars-temp-repo&lt;/id&gt;
          &lt;name&gt;A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.&lt;/name&gt;
          &lt;url&gt;file:${project.basedir}/lib&lt;/url&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
          &lt;id&gt;spring-milestone&lt;/id&gt;
          &lt;url&gt;http://repo.spring.io/libs-release&lt;/url&gt;
      &lt;/pluginRepository&gt;
  &lt;/pluginRepositories&gt;
  &lt;name&gt;cinemagik&lt;/name&gt;
  </code></pre>
  
  <p></p>
  
  <p>I tried multiple version of spring-ldap from the last release to the 1.3.1.</p>
  
  <p>Here is my code :</p>
  
  <p>WebAppConfiguration</p>
  
  <pre><code>package app.configuration;
  
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  
  @Configuration
  @EnableWebMvc
  @ComponentScan(basePackages = {"app"})
  public class WebAppConfiguration extends WebMvcConfigurerAdapter {
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
          registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
          registry.addResourceHandler("/images/**").addResourceLocations("classpath:/static/images/");
      }
  
      @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
      }
  }
  </code></pre>
  
  <p>SecurityConfig :</p>
  
  <pre><code>/*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package app.configuration;
  
  /**
   *
   * @author Antoine
   */
  import javax.inject.Inject;
  import javax.sql.DataSource;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.builders.WebSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.crypto.encrypt.Encryptors;
  import org.springframework.security.crypto.encrypt.TextEncryptor;
  import org.springframework.security.crypto.password.NoOpPasswordEncoder;
  import org.springframework.security.crypto.password.PasswordEncoder;
  
  /**
   * Security Configuration.
   *
   * @author Craig Walls
   */
  @Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private ApplicationContext context;
  
      @Inject
      private DataSource dataSource;
  
      @Autowired
      public void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
          auth.jdbcAuthentication()
                  .dataSource(dataSource)
                  .usersByUsernameQuery("select username, password, true from Account where username = ?")
                  .authoritiesByUsernameQuery("select username, 'ROLE_USER' from Account where username = ?")
                  .passwordEncoder(passwordEncoder());
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web
                  .ignoring()
                  .antMatchers("/**/*.css", "/**/*.png", "/**/*.gif", "/**/*.jpg");
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .formLogin()
                  .loginPage("/signin")
                  .loginProcessingUrl("/signin/authenticate")
                  .failureUrl("/signin?param.error=bad_credentials")
                  .and()
                  .logout()
                  .logoutUrl("/signout")
                  .deleteCookies("JSESSIONID")
                  .and()
                  .authorizeRequests()
                  .antMatchers("/admin/**", "/favicon.ico", "/resources/**", "/auth/**", "/signin/**", "/signup/**", "/disconnect/facebook").permitAll()
                  .antMatchers("/**").authenticated()
                  .and()
                  .rememberMe();
      }
  
      @Bean
      public PasswordEncoder passwordEncoder() {
          return NoOpPasswordEncoder.getInstance();
      }
  
      @Bean
      public TextEncryptor textEncryptor() {
          return Encryptors.noOpText();
      }
  
  }
  </code></pre>
  
  <p>Thanks for any help :o</p>