From 5d182c3472dba2d907b33f8ab456b2d3b57f9308 Mon Sep 17 00:00:00 2001 From: Shashank Date: Wed, 13 Oct 2021 16:39:17 +0530 Subject: [PATCH] moving spring-security-config module classes to spring-security-web-boot3 --- spring-security-modules/pom.xml | 1 - .../cache-control/README.md | 6 -- .../cache-control/pom.xml | 37 ----------- .../src/main/resources/logback.xml | 13 ---- .../spring-security-config/cors/README.md | 7 -- .../spring-security-config/cors/pom.xml | 64 ------------------- .../spring-security-config/pom.xml | 23 ------- .../spring-security-web-boot-3/README.md | 2 + .../com/baeldung/cachecontrol/AppRunner.java | 0 .../cachecontrol/ResourceEndpoint.java | 0 .../config/SpringSecurityConfig.java | 0 .../cachecontrol/model/TimestampDto.java | 0 .../baeldung/cachecontrol/model/UserDto.java | 0 .../SpringBootSecurityApplication.java | 4 +- .../basicauth/config/WebSecurityConfig.java | 2 +- .../cors}/controller/ResourceController.java | 6 +- .../ResourceEndpointIntegrationTest.java | 5 +- .../cachecontrol}/SpringContextTest.java | 4 +- .../cors}/ResourceControllerUnitTest.java | 9 ++- 19 files changed, 15 insertions(+), 168 deletions(-) delete mode 100644 spring-security-modules/spring-security-config/cache-control/README.md delete mode 100644 spring-security-modules/spring-security-config/cache-control/pom.xml delete mode 100644 spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml delete mode 100644 spring-security-modules/spring-security-config/cors/README.md delete mode 100644 spring-security-modules/spring-security-config/cors/pom.xml delete mode 100644 spring-security-modules/spring-security-config/pom.xml rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/main/java/com/baeldung/cachecontrol/AppRunner.java (100%) rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java (100%) rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java (100%) rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java (100%) rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/main/java/com/baeldung/cachecontrol/model/UserDto.java (100%) rename spring-security-modules/{spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors => spring-security-web-boot-3/src/main/java/com/baeldung/cors}/basicauth/SpringBootSecurityApplication.java (74%) rename spring-security-modules/{spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors => spring-security-web-boot-3/src/main/java/com/baeldung/cors}/basicauth/config/WebSecurityConfig.java (91%) rename spring-security-modules/{spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors => spring-security-web-boot-3/src/main/java/com/baeldung/cors}/controller/ResourceController.java (88%) rename spring-security-modules/{spring-security-config/cache-control => spring-security-web-boot-3}/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java (99%) rename spring-security-modules/{spring-security-config/cache-control/src/test/java/com/baeldung => spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol}/SpringContextTest.java (84%) rename spring-security-modules/{spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors => spring-security-web-boot-3/src/test/java/com/baeldung/cors}/ResourceControllerUnitTest.java (91%) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index e482a67a0e..9fdfde282d 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -21,7 +21,6 @@ spring-ldap spring-security-acl spring-security-auth0 - spring-security-config spring-security-core spring-security-ldap spring-security-legacy-oidc diff --git a/spring-security-modules/spring-security-config/cache-control/README.md b/spring-security-modules/spring-security-config/cache-control/README.md deleted file mode 100644 index 1c7cbfd096..0000000000 --- a/spring-security-modules/spring-security-config/cache-control/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Spring Security Cache Control - -This module contains articles about cache control with Spring Security - -### Relevant Articles: -- [Spring Security – Cache Control Headers](https://www.baeldung.com/spring-security-cache-control-headers) diff --git a/spring-security-modules/spring-security-config/cache-control/pom.xml b/spring-security-modules/spring-security-config/cache-control/pom.xml deleted file mode 100644 index b10d65615e..0000000000 --- a/spring-security-modules/spring-security-config/cache-control/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - cache-control - 1.0-SNAPSHOT - cache-control - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-test - test - - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml b/spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-config/cors/README.md b/spring-security-modules/spring-security-config/cors/README.md deleted file mode 100644 index c9e00e04d7..0000000000 --- a/spring-security-modules/spring-security-config/cors/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Spring Security CORS - -This module contains articles about Spring Security with CORS (Cross Origin Requests) - -## Relevant Articles - -- [Fixing 401s with CORS Preflights and Spring Security](https://www.baeldung.com/spring-security-cors-preflight) diff --git a/spring-security-modules/spring-security-config/cors/pom.xml b/spring-security-modules/spring-security-config/cors/pom.xml deleted file mode 100644 index b45f1b43e6..0000000000 --- a/spring-security-modules/spring-security-config/cors/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - cors - cors - jar - Spring Security CORS - - - com.baeldung - spring-security-modules - 0.0.1-SNAPSHOT - ../../ - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - 2.1.2.RELEASE - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-config/pom.xml b/spring-security-modules/spring-security-config/pom.xml deleted file mode 100644 index 8f82dcd40e..0000000000 --- a/spring-security-modules/spring-security-config/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - spring-security-config - 0.0.1-SNAPSHOT - spring-security-config - pom - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../../ - - - - cache-control - cors - - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-web-boot-3/README.md b/spring-security-modules/spring-security-web-boot-3/README.md index e02c8742bb..e95071b825 100644 --- a/spring-security-modules/spring-security-web-boot-3/README.md +++ b/spring-security-modules/spring-security-web-boot-3/README.md @@ -9,4 +9,6 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com - [TLS Setup in Spring](https://www.baeldung.com/spring-tls-setup) - [Spring Security – Request Rejected Exception](https://www.baeldung.com/spring-security-request-rejected-exception) +- [Spring Security – Cache Control Headers](https://www.baeldung.com/spring-security-cache-control-headers) +- [Fixing 401s with CORS Preflights and Spring Security](https://www.baeldung.com/spring-security-cors-preflight) - More articles: [[<-- prev]](/spring-security-modules/spring-security-web-boot-2) diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/AppRunner.java similarity index 100% rename from spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/AppRunner.java diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java similarity index 100% rename from spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java similarity index 100% rename from spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java similarity index 100% rename from spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/model/UserDto.java similarity index 100% rename from spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cachecontrol/model/UserDto.java diff --git a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/SpringBootSecurityApplication.java similarity index 74% rename from spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/SpringBootSecurityApplication.java index 89bf0dde5d..1272fee1da 100644 --- a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java +++ b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/SpringBootSecurityApplication.java @@ -1,10 +1,10 @@ -package com.baeldung.springbootsecuritycors.basicauth; +package com.baeldung.cors.basicauth; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages = "com.baeldung.springbootsecuritycors") +@SpringBootApplication(scanBasePackages = "com.baeldung.cors") @EnableAutoConfiguration public class SpringBootSecurityApplication { diff --git a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/config/WebSecurityConfig.java similarity index 91% rename from spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/config/WebSecurityConfig.java index 684354bf26..806fb9fca5 100644 --- a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java +++ b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/basicauth/config/WebSecurityConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.springbootsecuritycors.basicauth.config; +package com.baeldung.cors.basicauth.config; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; diff --git a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/controller/ResourceController.java similarity index 88% rename from spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java rename to spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/controller/ResourceController.java index 5d7d9f7770..5a650a2e51 100644 --- a/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java +++ b/spring-security-modules/spring-security-web-boot-3/src/main/java/com/baeldung/cors/controller/ResourceController.java @@ -1,11 +1,11 @@ -package com.baeldung.springbootsecuritycors.controller; - -import java.security.Principal; +package com.baeldung.cors.controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; +import java.security.Principal; + @RestController @CrossOrigin("http://localhost:4200") public class ResourceController { diff --git a/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java similarity index 99% rename from spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java rename to spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java index d4d24a4986..40ad05b1ce 100644 --- a/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java +++ b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java @@ -1,14 +1,13 @@ package com.baeldung.cachecontrol; -import static io.restassured.RestAssured.given; - +import io.restassured.http.ContentType; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit4.SpringRunner; -import io.restassured.http.ContentType; +import static io.restassured.RestAssured.given; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AppRunner.class) diff --git a/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/SpringContextTest.java similarity index 84% rename from spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/SpringContextTest.java index 0cde5d829d..342aacfc4c 100644 --- a/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cachecontrol/SpringContextTest.java @@ -1,12 +1,10 @@ -package com.baeldung; +package com.baeldung.cachecontrol; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.cachecontrol.AppRunner; - @RunWith(SpringRunner.class) @SpringBootTest(classes = AppRunner.class) public class SpringContextTest { diff --git a/spring-security-modules/spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cors/ResourceControllerUnitTest.java similarity index 91% rename from spring-security-modules/spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java rename to spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cors/ResourceControllerUnitTest.java index 7567573040..85f49faf11 100644 --- a/spring-security-modules/spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java +++ b/spring-security-modules/spring-security-web-boot-3/src/test/java/com/baeldung/cors/ResourceControllerUnitTest.java @@ -1,8 +1,6 @@ -package com.baeldung.springbootsecuritycors; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +package com.baeldung.cors; +import com.baeldung.cors.basicauth.SpringBootSecurityApplication; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,7 +12,8 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.springbootsecuritycors.basicauth.SpringBootSecurityApplication; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @SpringBootTest(classes = { SpringBootSecurityApplication.class })