Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| web:framework:spring:security [2025/11/04 11:29] – [Connexion à la console H2] jcheron | web:framework:spring:security [2025/12/15 09:18] (Version actuelle) – [Déclaration du service] jcheron | ||
|---|---|---|---|
| Ligne 39: | Ligne 39: | ||
| @Configuration | @Configuration | ||
| @EnableWebSecurity | @EnableWebSecurity | ||
| - | public class WebSecurityConfiguration | + | public class SecurityConfig |
| + | |||
| @Bean | @Bean | ||
| public SecurityFilterChain configure(HttpSecurity http) throws Exception { | public SecurityFilterChain configure(HttpSecurity http) throws Exception { | ||
| http.csrf(AbstractHttpConfigurer:: | http.csrf(AbstractHttpConfigurer:: | ||
| (req) -> req.requestMatchers( | (req) -> req.requestMatchers( | ||
| - | AntPathRequestMatcher.antMatcher("/" | + | PathPatternRequestMatcher.withDefaults().matcher("/" |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| ) | ) | ||
| .permitAll() | .permitAll() | ||
| .anyRequest() | .anyRequest() | ||
| .authenticated() | .authenticated() | ||
| - | | + | ); |
| return http.build(); | return http.build(); | ||
| } | } | ||
| Ligne 198: | Ligne 198: | ||
| @Bean | @Bean | ||
| public DaoAuthenticationProvider authenticationProvider(UserDetailsService userService) { | public DaoAuthenticationProvider authenticationProvider(UserDetailsService userService) { | ||
| - | DaoAuthenticationProvider auth = new DaoAuthenticationProvider(); | + | DaoAuthenticationProvider auth = new DaoAuthenticationProvider(userService); |
| - | auth.setUserDetailsService(userService); | + | |
| auth.setPasswordEncoder(getPasswordEncoder()); | auth.setPasswordEncoder(getPasswordEncoder()); | ||
| return auth; | return auth; | ||