Update samples to use Spring Security 6
Issue gh-46
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -18,9 +18,9 @@ package example;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
@@ -18,8 +18,8 @@ package example;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package example;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.j256.twofactorauth.TimeBasedOneTimePasswordUtil;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -51,8 +51,10 @@ public class LoginPage {
|
||||
|
||||
private WebDriver webDriver;
|
||||
|
||||
@FindBy(id = "username")
|
||||
private WebElement username;
|
||||
|
||||
@FindBy(id = "password")
|
||||
private WebElement password;
|
||||
|
||||
@FindBy(css = "button[type=submit]")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.6.4'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=5.7.0-SNAPSHOT
|
||||
spring-security.version=5.7.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -15,7 +15,7 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -225,7 +225,7 @@ public class OAuth2LoginApplicationTests {
|
||||
|
||||
HtmlElement errorElement = page.getBody().getFirstByXPath("div");
|
||||
assertThat(errorElement).isNotNull();
|
||||
assertThat(errorElement.asText()).contains("authorization_request_not_found");
|
||||
assertThat(errorElement.asNormalizedText()).contains("authorization_request_not_found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -253,7 +253,7 @@ public class OAuth2LoginApplicationTests {
|
||||
|
||||
HtmlElement errorElement = page.getBody().getFirstByXPath("div");
|
||||
assertThat(errorElement).isNotNull();
|
||||
assertThat(errorElement.asText()).contains("authorization_request_not_found");
|
||||
assertThat(errorElement.asNormalizedText()).contains("authorization_request_not_found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -291,7 +291,7 @@ public class OAuth2LoginApplicationTests {
|
||||
assertThat(clientAnchorElements.get(i).getAttribute("href")).isIn(googleClientAuthorizeUri,
|
||||
githubClientAuthorizeUri, facebookClientAuthorizeUri, oktaClientAuthorizeUri,
|
||||
springClientAuthorizeUri);
|
||||
assertThat(clientAnchorElements.get(i).asText()).isIn(googleClientRegistration.getClientName(),
|
||||
assertThat(clientAnchorElements.get(i).asNormalizedText()).isIn(googleClientRegistration.getClientName(),
|
||||
githubClientRegistration.getClientName(), facebookClientRegistration.getClientName(),
|
||||
oktaClientRegistration.getClientName(), springClientRegistration.getClientName());
|
||||
}
|
||||
@@ -301,13 +301,14 @@ public class OAuth2LoginApplicationTests {
|
||||
assertThat(page.getTitleText()).isEqualTo("Spring Security - OAuth 2.0 Login");
|
||||
|
||||
DomNodeList<HtmlElement> divElements = page.getBody().getElementsByTagName("div");
|
||||
assertThat(divElements.get(1).asText()).contains("User: joeg@springsecurity.io");
|
||||
assertThat(divElements.get(4).asText()).contains("You are successfully logged in joeg@springsecurity.io");
|
||||
assertThat(divElements.get(1).asNormalizedText()).contains("User: joeg@springsecurity.io");
|
||||
assertThat(divElements.get(4).asNormalizedText())
|
||||
.contains("You are successfully logged in joeg@springsecurity.io");
|
||||
}
|
||||
|
||||
private HtmlAnchor getClientAnchorElement(HtmlPage page, ClientRegistration clientRegistration) {
|
||||
Optional<HtmlAnchor> clientAnchorElement = page.getAnchors().stream()
|
||||
.filter((e) -> e.asText().equals(clientRegistration.getClientName())).findFirst();
|
||||
.filter((e) -> e.asNormalizedText().equals(clientRegistration.getClientName())).findFirst();
|
||||
|
||||
return (clientAnchorElement.orElse(null));
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ package example.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '2.6.4'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -31,7 +31,7 @@ dependencies {
|
||||
implementation 'com.squareup.okhttp3:mockwebserver'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'com.nimbusds:oauth2-oidc-sdk'
|
||||
implementation 'com.nimbusds:oauth2-oidc-sdk:9.29'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=5.7.0-SNAPSHOT
|
||||
spring-security.version=5.7.0-SNAPSHOT
|
||||
|
||||
@@ -7,4 +7,7 @@ spring:
|
||||
opaquetoken:
|
||||
introspection-uri: ${mockwebserver.url}/introspect
|
||||
client-id: client
|
||||
client-secret: secret
|
||||
client-secret: secret
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -31,7 +31,7 @@ dependencies {
|
||||
implementation 'com.squareup.okhttp3:mockwebserver'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'com.nimbusds:oauth2-oidc-sdk'
|
||||
implementation 'com.nimbusds:oauth2-oidc-sdk:9.29'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -32,7 +32,7 @@ dependencies {
|
||||
implementation 'org.springframework:spring-webflux'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
implementation 'io.projectreactor.netty:reactor-netty'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -22,7 +22,7 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.security:spring-security-saml2-service-provider'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
testImplementation 'net.sourceforge.htmlunit:htmlunit'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.2'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -22,11 +22,12 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.security:spring-security-saml2-service-provider'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
testImplementation 'net.sourceforge.htmlunit:htmlunit'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
testImplementation 'org.awaitility:awaitility:4.2.0'
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '2.5.6'
|
||||
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
|
||||
id 'org.springframework.boot' version '3.0.0-M1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id "nebula.integtest" version "8.2.0"
|
||||
id 'java'
|
||||
}
|
||||
@@ -22,7 +22,7 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.security:spring-security-saml2-service-provider'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
testImplementation 'net.sourceforge.htmlunit:htmlunit'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.6.0-SNAPSHOT
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
version=6.0.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("org.springframework.boot") version "2.5.0"
|
||||
id("io.spring.dependency-management") version "1.0.9.RELEASE"
|
||||
id("org.springframework.boot") version "3.0.0-M1"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
kotlin("jvm") version "1.6.0"
|
||||
kotlin("plugin.spring") version "1.6.0"
|
||||
}
|
||||
@@ -12,15 +12,16 @@ repositories {
|
||||
maven {
|
||||
url = uri("https://repo.spring.io/snapshot")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://repo.spring.io/milestone")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity5")
|
||||
implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
spring-security.version=5.6.0-SNAPSHOT
|
||||
spring-security.version=6.0.0-SNAPSHOT
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.security.samples.config
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
|
||||
import org.springframework.security.config.web.servlet.invoke
|
||||
import org.springframework.security.core.userdetails.User
|
||||
import org.springframework.security.core.userdetails.UserDetailsService
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager
|
||||
@@ -33,15 +32,11 @@ class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
||||
http {
|
||||
authorizeRequests {
|
||||
authorize("/css/**", permitAll)
|
||||
authorize("/user/**", hasAuthority("ROLE_USER"))
|
||||
}
|
||||
formLogin {
|
||||
loginPage = "/log-in"
|
||||
}
|
||||
}
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/css/**").permitAll()
|
||||
.antMatchers("/user/**").hasAuthority("ROLE_USER")
|
||||
.and()
|
||||
.formLogin().loginPage("/log-in")
|
||||
return http.build()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user