Update SecurityConfig.java
This commit is contained in:
parent
ba239764bf
commit
2e0c93a400
@ -33,15 +33,13 @@ public class SecurityConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
|
|
||||||
// TODO: Fix security config for this project (currently old state from sharepulse)
|
|
||||||
|
|
||||||
http
|
http
|
||||||
.csrf(csrf -> csrf.ignoringRequestMatchers("/api/v1/**")) // Disable CSRF for API routes
|
.csrf(csrf -> csrf.ignoringRequestMatchers("/api/v1/**")) // Disable CSRF for API routes
|
||||||
.sessionManagement(sessionManagement -> sessionManagement
|
.sessionManagement(sessionManagement -> sessionManagement
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // No session will be created by Spring Security
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) // No session will be created by Spring Security
|
||||||
)
|
)
|
||||||
.authorizeHttpRequests(authorize -> authorize
|
.authorizeHttpRequests(authorize -> authorize
|
||||||
.requestMatchers("/api/v1/secure/**").authenticated() // Secure these endpoints
|
.requestMatchers("/api/v1/**").authenticated() // Secure all /api/v1/** routes
|
||||||
.anyRequest().permitAll() // All other requests are allowed without authentication
|
.anyRequest().permitAll() // All other requests are allowed without authentication
|
||||||
)
|
)
|
||||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) // Apply JWT filter
|
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) // Apply JWT filter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user