Update samples to use Spring Security 6

Issue gh-46
This commit is contained in:
Marcus Da Coregio
2022-03-17 14:44:26 -03:00
parent 545ffedea3
commit bce2126fd1
101 changed files with 347 additions and 306 deletions

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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]")

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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));
}

View File

@@ -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;

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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'
}

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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'

View File

@@ -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