Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.0.7-SNAPSHOT
version=0.1.0-SNAPSHOT
5 changes: 3 additions & 2 deletions samples/oauth2-login-custom-config/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.2'
id 'org.springframework.boot' version '4.0.0-RC1'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.example'
Expand All @@ -22,6 +22,7 @@ dependencies {
testImplementation project(':spring-boot-testjars-maven')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-oauth2-authorization-server'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.springframework.security.config.Customizer;
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.OAuth2AuthorizationServerConfiguration;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.authorization.OAuth2AuthorizationServerConfigurer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
Expand All @@ -38,8 +40,6 @@
import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer;
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
Expand All @@ -59,9 +59,14 @@ public class SecurityConfig {

@Bean
@Order(1)
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http)
throws Exception {
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) {
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer();
http
.securityMatcher(authorizationServerConfigurer.getEndpointsMatcher())
.with(authorizationServerConfigurer, Customizer.withDefaults())
.authorizeHttpRequests((authorize) ->
authorize.anyRequest().authenticated()
);
http.getConfigurer(OAuth2AuthorizationServerConfigurer.class)
.oidc(Customizer.withDefaults()); // Enable OpenID Connect 1.0
http
Expand All @@ -82,8 +87,7 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h

@Bean
@Order(2)
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http)
throws Exception {
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) {
http
.authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated()
Expand All @@ -96,6 +100,7 @@ public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http)
return http.build();
}

@SuppressWarnings("deprecation")
@Bean
public UserDetailsService userDetailsService() {
UserDetails userDetails = User.withDefaultPasswordEncoder()
Expand Down
5 changes: 3 additions & 2 deletions samples/oauth2-login/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.0'
id 'io.spring.dependency-management' version '1.1.2'
id 'org.springframework.boot' version '4.0.0-RC1'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.example'
Expand All @@ -21,6 +21,7 @@ dependencies {
testImplementation project(':spring-boot-testjars')
testImplementation project(':spring-boot-testjars-maven')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
Expand Down
4 changes: 3 additions & 1 deletion spring-boot-testjars-maven/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ checkstyle {
dependencies {
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.40")
api project(':spring-boot-testjars')
api platform('org.springframework.boot:spring-boot-dependencies:3.4.0')
api platform('org.springframework.boot:spring-boot-dependencies:4.0.0-RC1')
api 'org.springframework.boot:spring-boot-starter'
api 'org.springframework.boot:spring-boot-web-server'
api "org.apache.maven:maven-resolver-provider:${mavenVersion}"
api "org.apache.maven.resolver:maven-resolver-api:${mavenResolverVersion}"
api "org.apache.maven.resolver:maven-resolver-spi:${mavenResolverVersion}"
Expand All @@ -42,6 +43,7 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework:spring-web'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
Expand Down
4 changes: 3 additions & 1 deletion spring-boot-testjars/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ checkstyle {
dependencies {
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.40")
compileOnly 'org.springframework.boot:spring-boot-loader'
implementation platform('org.springframework.boot:spring-boot-dependencies:3.4.0')
implementation platform('org.springframework.boot:spring-boot-dependencies:4.0.0-RC1')
implementation 'org.apache.commons:commons-exec:1.3'
implementation 'org.springframework:spring-test'
implementation 'org.springframework.boot:spring-boot-testcontainers'
implementation 'org.springframework.boot:spring-boot-web-server'
testImplementation 'org.springframework.boot:spring-boot-loader'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework:spring-web'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class ClassUtils {
* @throws LinkageError if the class file could not be loaded
* @see Class#forName(String, boolean, ClassLoader)
*/
@SuppressWarnings("deprecation")
static Class<?> forName(String name, @Nullable ClassLoader classLoader)
throws ClassNotFoundException, LinkageError {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@
package org.springframework.experimental.boot.test.context;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.DynamicPropertyRegistrar;

/**
* Automatically imports {@code EnableDynamicProperty}.
*
* @author Rob Winch
* @author Chris Bono
*/
@AutoConfiguration
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnClass(DynamicPropertyRegistrar.class)
@EnableDynamicProperty
public class DynamicPropertyAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,21 +25,20 @@
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.testcontainers.properties.TestcontainersPropertySource;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata;
import org.springframework.test.context.DynamicPropertyRegistrar;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.util.ClassUtils;

/**
* Finds beans annotated with {@link DynamicProperty} and adds the properties to the
* Environment.
*
* @author Rob Winch
* @author Chris Bono
*/
class DynamicPropertyDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

Expand All @@ -63,13 +62,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
return;
}
if (this.beanFactory instanceof ConfigurableListableBeanFactory listableBeanFactory) {
if (ClassUtils.isPresent("org.springframework.test.context.DynamicPropertyRegistrar",
getClass().getClassLoader())) {
registerDynamicPropertyRegistrar(listableBeanFactory, registry);
}
else {
registerTestcontainersPropertySource(listableBeanFactory, registry);
}
registerDynamicPropertyRegistrar(listableBeanFactory, registry);
}
}

Expand All @@ -93,21 +86,6 @@ private void registerDynamicPropertyRegistrar(ConfigurableListableBeanFactory be
registry.registerBeanDefinition(REGISTRAR_BEAN_NAME, registrarBdb.getBeanDefinition());
}

private void registerTestcontainersPropertySource(ConfigurableListableBeanFactory beanFactory,
BeanDefinitionRegistry registry) {
DynamicPropertyRegistry properties = TestcontainersPropertySource.attach(this.environment);
for (String dynamicPropertyBeanName : beanFactory.getBeanNamesForAnnotation(DynamicProperty.class)) {
BeanDefinition dynamicPropertyBeanDefinition = registry.getBeanDefinition(dynamicPropertyBeanName);
DynamicPropertyRegistryProperty property = createRegistryProperty(dynamicPropertyBeanDefinition,
dynamicPropertyBeanName);
if (property == null) {
throw new IllegalStateException(
"Missing @DynamicProperty annotation on BeanDefinition of " + dynamicPropertyBeanName);
}
properties.add(property.name(), property.value());
}
}

private DynamicPropertyRegistryProperty createRegistryProperty(BeanDefinition dynamicPropertyBeanDefinition,
String dynamicPropertyBeanName) {
if (dynamicPropertyBeanDefinition instanceof AnnotatedBeanDefinition annotatedBeanDefinition) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.springframework.context.ApplicationListener=\
org.springframework.boot.web.context.WebServerPortFileWriter
org.springframework.boot.web.server.context.WebServerPortFileWriter