package br.com.minitwitter;

import org.springframework.beans.factory.annotation.Autowired;
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.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import br.com.minitwitter.service.UserService;


@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

  @Autowired
  private UserService userService;

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
        .antMatchers("/**").permitAll().anyRequest().authenticated().and()
        .formLogin().loginPage("/login").permitAll().and().logout()
        .logoutRequestMatcher(new AntPathRequestMatcher("/logout"));

  }

  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {

    auth.userDetailsService(userService);

  }

}
@@ -146,16 +146,60 @@
 ration;%0A
+import org.springframework.http.HttpMethod;%0A
 import o
@@ -294,24 +294,24 @@
 gerBuilder;%0A
-
 import org.s
@@ -697,17 +697,16 @@
 rvice;%0A%0A
-%0A
 @Configu
@@ -956,25 +956,180 @@
 quests()
-%0A        
+.antMatchers(%22/notification%22, %22/feed%22)%0A        .hasRole(%22NOMARL%22)%0A        .antMatchers(HttpMethod.POST, %22/follow%22, %22/unfollow%22, %22/tweet%22)%0A        .hasRole(%22NORMAL%22)
 .antMatc
@@ -1164,16 +1164,25 @@
 equest()
+%0A        
 .authent
@@ -1195,25 +1195,16 @@
 ().and()
-%0A        
 .formLog
@@ -1249,17 +1249,8 @@
 nd()
-.logout()
 %0A   
@@ -1254,16 +1254,25 @@
         
+.logout()
 .logoutR

update WebSecurityConfig