package tenttiarkisto.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import tenttiarkisto.auth.JpaAuthenticationProvider;

@Configuration
@EnableWebMvcSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable();
                
        http.authorizeRequests()
                .anyRequest().permitAll();

        http.formLogin()
                .loginPage("/kirjaudu")
                .loginProcessingUrl("/tervetuloa")
                .defaultSuccessUrl("/kurssit")
                .usernameParameter("kayttaja")
                .passwordParameter("salasana")
                .permitAll();

        http.logout()
                .logoutUrl("/logout")
                .logoutSuccessUrl("/kirjaudu")
                .permitAll()
                .invalidateHttpSession(true);

    }

    @Configuration
    protected static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {

        @Autowired
        private JpaAuthenticationProvider jpaAuthenticationProvider;

        @Override
        public void init(AuthenticationManagerBuilder auth) throws Exception {
            auth.authenticationProvider(jpaAuthenticationProvider);
        }
    }
}

@@ -1057,28 +1057,368 @@
  .an
-yRequest().permitAll
+tMatchers(%22/kurssit/*%22).permitAll()%0A                .antMatchers(%22/kurssit%22).permitAll()%0A                .antMatchers(%22/%22).permitAll()%0A                .antMatchers(%22/assets/*%22).permitAll()%0A                .antMatchers(%22/kirjaudu%22).permitAll()%0A                .antMatchers(%22/kommentit/*%22).permitAll()%0A                %0A                .anyRequest().authenticated
 ();%0A

Whitelist Security