-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevSecurityConfig.java
More file actions
38 lines (33 loc) · 1.14 KB
/
Copy pathDevSecurityConfig.java
File metadata and controls
38 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.example.onlinejava;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
/**
* Security configuration active under the {@code dev} profile, allowing all
* requests without authentication for local development.
*/
@Configuration
@Profile("dev")
public class DevSecurityConfig {
/**
* Builds a permissive security filter chain that permits all requests
* and disables CSRF protection, for local development only.
*
* @param http the security configuration builder
* @return the configured filter chain
* @throws Exception if the security configuration cannot be built
*/
@Bean
public SecurityFilterChain devSecurityFilterChain(HttpSecurity http)
throws Exception {
http
.authorizeHttpRequests(authorize -> authorize
.anyRequest()
.permitAll()
)
.csrf(csrf -> csrf.disable());
return http.build();
}
}