Skip to content

Commit 2f40755

Browse files
committed
Adapt to deprecation in Spring Security snapshots
See gh-44598
1 parent 4846696 commit 2f40755

File tree

2 files changed

+6
-4
lines changed
  • spring-boot-project/spring-boot-docs/src/main

2 files changed

+6
-4
lines changed

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import org.springframework.context.annotation.Bean;
2020
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.security.config.Customizer;
2122
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2223
import org.springframework.security.web.SecurityFilterChain;
2324

@@ -27,7 +28,7 @@ public class MySecurityConfig {
2728
@Bean
2829
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
2930
// Customize the application security ...
30-
http.requiresChannel((channel) -> channel.anyRequest().requiresSecure());
31+
http.redirectToHttps(Customizer.withDefaults());
3132
return http.build();
3233
}
3334

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.boot.docs.howto.security.enablehttps
1818

1919
import org.springframework.context.annotation.Bean
2020
import org.springframework.context.annotation.Configuration
21+
import org.springframework.security.config.Customizer
2122
import org.springframework.security.config.annotation.web.builders.HttpSecurity
2223
import org.springframework.security.web.SecurityFilterChain
2324

@@ -27,7 +28,7 @@ class MySecurityConfig {
2728
@Bean
2829
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
2930
// Customize the application security ...
30-
http.requiresChannel { requests -> requests.anyRequest().requiresSecure() }
31+
http.redirectToHttps { }
3132
return http.build()
3233
}
3334

0 commit comments

Comments
 (0)