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 Prochaine révisionLes deux révisions suivantes | ||
web:framework:spring:security [2023/12/05 11:03] – [Login form personnalisée] jcheron | web:framework:spring:security [2023/12/05 11:35] – [Configuration des rôles] jcheron | ||
---|---|---|---|
Ligne 267: | Ligne 267: | ||
@Configuration | @Configuration | ||
@EnableWebSecurity | @EnableWebSecurity | ||
- | @EnableMethodSecurity( | ||
- | prePostEnabled = true, proxyTargetClass = true | ||
- | ) | ||
public class WebSecurityConfiguration { | public class WebSecurityConfiguration { | ||
Ligne 326: | Ligne 323: | ||
static RoleHierarchy roleHierarchy() { | static RoleHierarchy roleHierarchy() { | ||
RoleHierarchyImpl hierarchy = new RoleHierarchyImpl(); | RoleHierarchyImpl hierarchy = new RoleHierarchyImpl(); | ||
- | hierarchy.setHierarchy(" | + | hierarchy.setHierarchy(" |
return hierarchy; | return hierarchy; | ||
} | } | ||
Ligne 366: | Ligne 363: | ||
) | ) | ||
.permitAll(); | .permitAll(); | ||
- | req.requestMatchers(AntPathRequestMatcher.antMatcher("/ | + | req.requestMatchers(AntPathRequestMatcher.antMatcher("/ |
req.requestMatchers(AntPathRequestMatcher.antMatcher("/ | req.requestMatchers(AntPathRequestMatcher.antMatcher("/ | ||
req.requestMatchers(AntPathRequestMatcher.antMatcher("/ | req.requestMatchers(AntPathRequestMatcher.antMatcher("/ | ||
Ligne 476: | Ligne 473: | ||
La protection csrf est activée par défaut dans **Spring security** | La protection csrf est activée par défaut dans **Spring security** | ||
</ | </ | ||
+ | |||
+ | Mettre éventuellement une exception pour la console H2 (mais la console H2 n'a aucune raison d' | ||
+ | |||
+ | <sxh java; | ||
+ | req.csrf(csrf-> | ||
+ | </ | ||
=== Intégration dans les vues === | === Intégration dans les vues === | ||
Ligne 497: | Ligne 500: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | |||
+ | <wrap important> | ||