/**
 * MIT License
 *
 * Copyright (c) 2017 Wreulicke
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.wreulicke.simple;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

  private final UserDetailsService userDetailsService;

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.httpBasic()
      .realmName("test")
      .and()
      .csrf()
      .disable()
      .authorizeRequests()
      .anyRequest()
      .authenticated();
  }

  @Bean
  public PasswordEncoder bcrpt() {
    return new BCryptPasswordEncoder();
  }

}

@@ -1464,81 +1464,8 @@
 er;%0A
-import org.springframework.security.core.userdetails.UserDetailsService;%0A
 impo
@@ -1606,73 +1606,156 @@
 er;%0A
-%0Aimport lombok.RequiredArgsConstructor;%0A%0A@RequiredArgsConstructor
+import org.springframework.security.web.csrf.CookieCsrfTokenRepository;%0Aimport org.springframework.security.web.util.matcher.AntPathRequestMatcher;%0A
 %0A@Co
@@ -1844,67 +1844,11 @@
 r %7B%0A
-%0A  private final UserDetailsService userDetailsService;%0A%0A  
+%09%0A%09
 @Ove
@@ -1853,18 +1853,17 @@
 verride%0A
-  
+%09
 protecte
@@ -1921,184 +1921,479 @@
 n %7B%0A
-    
+%09%09
 http.
-httpBasic()%0A      .realmName(%22test%22)%0A      .and()%0A      .csrf()%0A      .disable()%0A      .authorizeRequests()%0A      .anyRequest()%0A      .authenticated();%0A  %7D%0A%0A  
+csrf()%0A%09%09%09.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());%0A%09%09%0A%09%09http%0A%09%09%09.authorizeRequests()%0A%09%09%09.antMatchers(%22/login%22).permitAll()%0A%09%09%09.anyRequest().authenticated().and()%0A%09%09%09.httpBasic().realmName(%22clients%22).and()%0A%09%09%09.formLogin()%0A%09%09%09.loginProcessingUrl(%22/login%22)%0A%09%09%09.loginPage(%22/login%22)%0A%09%09%09.defaultSuccessUrl(%22/%22)%0A%09%09%09.and()%0A%09%09%09.logout()%0A%09%09%09.logoutRequestMatcher(new AntPathRequestMatcher(%22/logout%22))%0A%09%09%09.logoutSuccessUrl(%22/login%22);%0A%09%7D%0A%09%0A%09
 @Bean%0A
-  
+%09
 publ
@@ -2425,12 +2425,10 @@
 ) %7B%0A
-    
+%09%09
 retu
@@ -2463,11 +2463,9 @@
 ();%0A
-  %7D%0A
+%09%7D
 %0A%7D%0A

add security settings