File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ This project is sponsored by
5757 - [ Adding API Information and Security documentation] ( #adding-api-information-and-security-documentation )
5858 - [ spring-webflux support with Annotated Controllers] ( #spring-webflux-support-with-annotated-controllers )
5959 - [ Using a separate management port (Spring Boot 3)] ( #using-a-separate-management-port-spring-boot-3 )
60+ - [ When Spring Security is enabled] ( #when-spring-security-is-enabled )
6061- [ Acknowledgements] ( #acknowledgements )
6162 - [ Contributors] ( #contributors )
6263 - [ Additional Support] ( #additional-support )
@@ -285,6 +286,28 @@ management:
285286# (OpenAPI JSON = /v3/api-docs, Swagger UI = /swagger-ui/index.html)
286287```
287288
289+ ### When Spring Security is enabled
290+
291+ With Spring Boot 3, ` /v3/api-docs ` and Swagger UI are served on the ** application port** , while Actuator runs on the ** management port** .
292+ If Spring Security is enabled, explicitly permit the docs paths on the ** application port** :
293+
294+ ``` java
295+ @Bean
296+ SecurityFilterChain api(HttpSecurity http) throws Exception {
297+ http
298+ .authorizeHttpRequests(auth - > auth
299+ .requestMatchers(
300+ " /v3/api-docs/**" ,
301+ " /v3/api-docs.yaml" ,
302+ " /swagger-ui/**" ,
303+ " /swagger-ui.html"
304+ ). permitAll()
305+ .anyRequest(). authenticated()
306+ );
307+ return http. build();
308+ }
309+ ```
310+
288311# Acknowledgements
289312
290313## Contributors
You can’t perform that action at this time.
0 commit comments