package de.uni_koeln.spinfo.upcase.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;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

	@Autowired
	public void configureGlobal(AuthenticationManagerBuilder auth)
			throws Exception {
		auth.inMemoryAuthentication()
			.withUser("user")
				.password("password")
				.roles("USER")
				.and()
			.withUser("admin")
				.password("secret")
				.roles("ADMIN");
	}

	protected void configure(HttpSecurity http) throws Exception {
		http.authorizeRequests()
				.antMatchers("/resources/**", "/signup", "/about").permitAll()
				.antMatchers("/admin/**").hasRole("ADMIN")
				.and()
			.formLogin()
				.and()
			.logout()
				.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
				.logoutSuccessUrl("/");
	}

}

@@ -789,15 +789,15 @@
 ity(
-secured
+prePost
 Enab
@@ -876,16 +876,35 @@
 pter %7B%0A%0A
+%09// @formatter:off%0A
 %09@Autowi
@@ -970,20 +970,17 @@
 er auth)
-%0A%09%09%09
+ 
 throws E
@@ -1021,20 +1021,16 @@
 cation()
-%0A%09%09%09
 .withUse
@@ -1036,45 +1036,199 @@
 er(%22
-user%22)%0A%09%09%09%09.password(%22password%22)%0A%09%09%09%09
+editor%22).password(%22editor%22).roles(%22USER%22);%0A%09%09auth.inMemoryAuthentication().withUser(%22guest%22).password(%22guest%22).roles(%22USER%22);%0A%09%09auth.inMemoryAuthentication().withUser(%22user%22).password(%22user%22)
 .rol
@@ -1241,101 +1241,316 @@
 ER%22)
+;
 %0A%09%09
-%09%09.and()%0A%09%09%09.withUser(%22admin%22)%0A%09%09%09%09.password(%22secret
+auth.inMemoryAuthentication().withUser(%22admin%22).password(%22admin%22).roles(%22ADMIN%22);%0A%09%09auth.inMemoryAuthentication().withUser(%22superuser%22).password(%22superuser%22).roles(%22USER%22, %22ADMIN
 %22)
+;
 %0A%09%09
-%09%09.roles(%22ADMIN
+auth.inMemoryAuthentication().withUser(%22god%22).password(%22god%22).roles(%22USER%22, %22ADMIN%22, %22CREATER
 %22);%0A%09%7D%0A
+%09
 %0A%09
-protected
+@Override%0A%09public
  voi
@@ -1605,16 +1605,19 @@
 %7B%0A%09%09http
+%0A%09%09
 .authori
@@ -1628,25 +1628,24 @@
 quests()%0A%09%09%09
-%09
 .antMatchers
@@ -1651,43 +1651,16 @@
 s(%22/
-resources/**%22, %22/signup%22, %22/about%22)
+**%22)%0A%09%09%09
 .per
@@ -1668,17 +1668,16 @@
 itAll()%0A
-%09
 %09%09%09.antM
@@ -1700,17 +1700,29 @@
 **%22)
-.
+%0A%09%09%09.access(%22
 hasRole(
 %22ADM
@@ -1721,19 +1721,19 @@
 ole(
-%22
+'
 ADMIN
+')
 %22)%0A
-%09%09
 %09%09.a
@@ -1756,16 +1756,264 @@
 in()%0A%09%09%09
+.loginPage(%22/login%22)%0A%09%09%09.usernameParameter(%22emailID%22)%0A%09%09%09.passwordParameter(%22passwd%22)%0A%09%09%09.permitAll()%0A%09%09.and()%0A%09%09%09.logout()%0A%09%09%09.logoutUrl(%22/logout%22)%0A%09%09%09.logoutSuccessUrl(%22/%22)%0A%09%09.and()%0A%09%09%09.exceptionHandling()%0A%09%09%09.accessDeniedPage(%22/access_denied%22)%0A%09
 %09.and()%0A
@@ -2025,17 +2025,16 @@
 ogout()%0A
-%09
 %09%09%09.logo
@@ -2089,16 +2089,31 @@
 out%22))%0A%09
+%09%09.permitAll()%0A
 %09%09%09.logo
@@ -2129,16 +2129,59 @@
 Url(%22/%22)
-;%0A%09%7D
+%0A%09%09.and()%0A%09%09%09.httpBasic();%0A%09%7D%0A%09// @formatter:on
 %0A%0A%7D%0A

Configure app security