package hello.config;

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.method.configuration.EnableGlobalMethodSecurity;
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;

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class Security extends WebSecurityConfigurerAdapter {

	public static final String ADMIN_ROLE = "ADMINISTRATOR";

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		// Use form login for the Web, and HTTP basic for the API.
		http.authorizeRequests().anyRequest().permitAll().and().formLogin().loginPage("/sign-in").permitAll().and()
				.logout().logoutUrl("/sign-out").logoutSuccessUrl("/").permitAll().and().httpBasic();
	}

	@Autowired
	public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
		auth.inMemoryAuthentication().withUser("Rob").password("Haines").roles(ADMIN_ROLE).and().withUser("Caroline")
		.password("Jay").roles(ADMIN_ROLE).and().withUser("Markel").password("Vigo").roles(ADMIN_ROLE);
	}
}

@@ -911,67 +911,78 @@
 n %7B%0A
+%0A
 %09%09// 
-Use form login for the Web, and HTTP basic for the API
+Allow all requests and we use method security in the controllers
 .%0A%09%09
@@ -1030,22 +1030,65 @@
 mitAll()
-.and()
+;%0A%0A%09%09// Use form login/logout for the Web.%0A%09%09http
 .formLog
@@ -1129,19 +1129,16 @@
 ll()
-.and()%0A%09%09%09%09
+;%0A%09%09http
 .log
@@ -1199,22 +1199,58 @@
 mitAll()
-.and()
+;%0A%0A%09%09// Use HTTP basic for the API.%0A%09%09http
 .httpBas

Split up the HTTP security config for readability.