Spring Security Javaconfig

Dave Syer, 2013
Twitter: @david_syer
Email: dsyer@gopivotal.com

Agenda

What's Happening

Getting Started 1

:::java
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {

}    

Getting Started 2

:::java
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {

   @Bean
    public AuthenticationManager authenticationManager() throws Exception {
        return new AuthenticationBuilder().inMemoryAuthentication().withUser("user")
            .password("password").roles("USER").and().and().build();
    }

}

Getting Started 3

:::java
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

   @Bean
    public AuthenticationManager authenticationManager() throws Exception {
        return new AuthenticationBuilder().inMemoryAuthentication().withUser("user")
            .password("password").roles("USER").and().and().build();
    }

    @Override
    protected void configure(HttpConfigurator http) throws Exception {
        http.authorizeUrls()
              .antMatchers("/**").authenticated()
          .and()
              .formLogin().permitAll();
    }

}

Demo

XML -> @Configuration
#