diff --git a/spring-boot-auditing/.gitignore b/spring-boot-auditing/.gitignore deleted file mode 100644 index 31ce405488..0000000000 --- a/spring-boot-auditing/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/target/ -.settings/ -.classpath -.project -*.iml -.idea \ No newline at end of file diff --git a/spring-boot-auditing/pom.xml b/spring-boot-auditing/pom.xml deleted file mode 100644 index 0afbe0becc..0000000000 --- a/spring-boot-auditing/pom.xml +++ /dev/null @@ -1,198 +0,0 @@ - - 4.0.0 - com.baeldung - spring-boot-auditing - 0.0.1-SNAPSHOT - war - spring-boot-auditing - This is simple boot application for Spring boot auditing test - - - - org.springframework.boot - spring-boot-starter-parent - 1.5.2.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-security - - - - io.dropwizard.metrics - metrics-core - - - - com.h2database - h2 - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter - - - com.jayway.jsonpath - json-path - test - - - org.springframework.boot - spring-boot-starter-mail - - - org.subethamail - subethasmtp - ${subethasmtp.version} - test - - - - org.webjars - bootstrap - ${bootstrap.version} - - - org.webjars - jquery - ${jquery.version} - - - - org.apache.tomcat - tomcat-servlet-api - ${tomee-servlet-api.version} - provided - - - - - - spring-boot - - - src/main/resources - true - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-war-plugin - - - - pl.project13.maven - git-commit-id-plugin - ${git-commit-id-plugin.version} - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - **/*LiveTest.java - - - - - - - - - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - - - **/*IntegrationTest.java - - - - - - - json - - - - - - - - - - - UTF-8 - 1.8 - 4.3.7.RELEASE - 2.2.1 - 3.1.1 - 3.3.7-1 - 3.1.7 - 8.5.11 - - - diff --git a/spring-boot-auditing/src/main/java/org/baeldung/Application.java b/spring-boot-auditing/src/main/java/org/baeldung/Application.java deleted file mode 100755 index bf7b7bd1a6..0000000000 --- a/spring-boot-auditing/src/main/java/org/baeldung/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.baeldung; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) throws Throwable { - SpringApplication.run(Application.class, args); - } - -} diff --git a/spring-boot-auditing/src/main/java/org/baeldung/MvcConfig.java b/spring-boot-auditing/src/main/java/org/baeldung/MvcConfig.java deleted file mode 100755 index fecb8c5c0b..0000000000 --- a/spring-boot-auditing/src/main/java/org/baeldung/MvcConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.baeldung; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Configuration -public class MvcConfig extends WebMvcConfigurerAdapter { - - @Override - public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/home").setViewName("home"); - registry.addViewController("/").setViewName("home"); - registry.addViewController("/hello").setViewName("hello"); - registry.addViewController("/login").setViewName("login"); - } - -} diff --git a/spring-boot-auditing/src/main/java/org/baeldung/WebSecurityConfig.java b/spring-boot-auditing/src/main/java/org/baeldung/WebSecurityConfig.java deleted file mode 100755 index 9339d8e804..0000000000 --- a/spring-boot-auditing/src/main/java/org/baeldung/WebSecurityConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.baeldung; - -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.WebSecurityConfigurerAdapter; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .authorizeRequests() - .antMatchers("/", "/home").permitAll() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .permitAll() - .and() - .logout() - .permitAll(); - } - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth - .inMemoryAuthentication() - .withUser("user").password("password").roles("USER", "ACTUATOR"); - } -} diff --git a/spring-boot-auditing/src/main/resources/application.properties b/spring-boot-auditing/src/main/resources/application.properties deleted file mode 100644 index cf09473b60..0000000000 --- a/spring-boot-auditing/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -logging.level.org.springframework=INFO \ No newline at end of file diff --git a/spring-boot-auditing/src/main/resources/logback.xml b/spring-boot-auditing/src/main/resources/logback.xml deleted file mode 100644 index 78913ee76f..0000000000 --- a/spring-boot-auditing/src/main/resources/logback.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - \ No newline at end of file diff --git a/spring-boot-auditing/src/main/resources/templates/hello.html b/spring-boot-auditing/src/main/resources/templates/hello.html deleted file mode 100755 index 46feef7e2c..0000000000 --- a/spring-boot-auditing/src/main/resources/templates/hello.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - Hello World! - - -

Hello [[${#httpServletRequest.remoteUser}]]!

-
- -
- - \ No newline at end of file diff --git a/spring-boot-auditing/src/main/resources/templates/home.html b/spring-boot-auditing/src/main/resources/templates/home.html deleted file mode 100755 index fe4e8b337e..0000000000 --- a/spring-boot-auditing/src/main/resources/templates/home.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - Spring Security Example - - -

Welcome!

- -

Click here to see a greeting.

- - \ No newline at end of file diff --git a/spring-boot-auditing/src/main/resources/templates/login.html b/spring-boot-auditing/src/main/resources/templates/login.html deleted file mode 100755 index a1785313f5..0000000000 --- a/spring-boot-auditing/src/main/resources/templates/login.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Spring Security Example - - -
- Invalid username and password. -
-
- You have been logged out. -
-
-
-
-
-
- - \ No newline at end of file diff --git a/spring-security-core/pom.xml b/spring-security-core/pom.xml index a8ffce84b7..971f5a9d0f 100644 --- a/spring-security-core/pom.xml +++ b/spring-security-core/pom.xml @@ -32,6 +32,10 @@ org.springframework.boot spring-boot-starter-thymeleaf + + org.springframework.boot + spring-boot-starter-actuator + com.h2database h2 diff --git a/spring-boot-auditing/src/main/java/org/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java b/spring-security-core/src/main/java/org/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java similarity index 100% rename from spring-boot-auditing/src/main/java/org/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java rename to spring-security-core/src/main/java/org/baeldung/auditing/ExposeAttemptedPathAuthorizationAuditListener.java diff --git a/spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java b/spring-security-core/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java similarity index 72% rename from spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java rename to spring-security-core/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java index 5be8cebfd3..bf0781bced 100644 --- a/spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java +++ b/spring-security-core/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java @@ -15,11 +15,11 @@ public class LoginAttemptsLogger { @EventListener public void auditEventHappened(AuditApplicationEvent auditApplicationEvent) { AuditEvent auditEvent = auditApplicationEvent.getAuditEvent(); - LOGGER.debug("Principal " + auditEvent.getPrincipal() + " - " + auditEvent.getType()); + LOGGER.info("Principal " + auditEvent.getPrincipal() + " - " + auditEvent.getType()); WebAuthenticationDetails details = (WebAuthenticationDetails) auditEvent.getData().get("details"); - LOGGER.debug(" Remote IP address: " + details.getRemoteAddress()); - LOGGER.debug(" Session Id: " + details.getSessionId()); - LOGGER.debug(" Request URL: " + auditEvent.getData().get("requestUrl")); + LOGGER.info(" Remote IP address: " + details.getRemoteAddress()); + LOGGER.info(" Session Id: " + details.getSessionId()); + LOGGER.info(" Request URL: " + auditEvent.getData().get("requestUrl")); } } diff --git a/spring-security-core/src/main/java/org/baeldung/config/WebSecurityConfig.java b/spring-security-core/src/main/java/org/baeldung/config/WebSecurityConfig.java index 5441dac7f7..0b6cd34f3e 100644 --- a/spring-security-core/src/main/java/org/baeldung/config/WebSecurityConfig.java +++ b/spring-security-core/src/main/java/org/baeldung/config/WebSecurityConfig.java @@ -20,6 +20,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication().withUser("jim").password("jim").roles("USER").and().withUser("pam").password("pam").roles("USER").and().withUser("michael").password("michael").roles("MANAGER"); + auth.inMemoryAuthentication() + .withUser("jim").password("jim").roles("USER", "ACTUATOR") + .and().withUser("pam").password("pam").roles("USER") + .and().withUser("michael").password("michael").roles("MANAGER"); } }