Spring Security Configuration
Secure Applications
Authentication, authorization, JWT token support.
Security Setup
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) {
return http.authorizeHttpRequests(auth -> auth
.requestMatchers("/public/**").permitAll()
.anyRequest().authenticated()
).build();
}
}Security Features
- OAuth2 resource server
- JWT token validation
- Method security (@PreAuthorize)
- Custom UserDetailsService