Changed permission management to a safer one

This commit is contained in:
Alexis Leboeuf
2026-01-12 14:04:57 +01:00
parent 158ee781c6
commit e4dd334832

View File

@@ -30,11 +30,9 @@ public class WebSecurityConfig {
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// 2. Allow public endpoints BEFORE any authenticated() calls // 2. Allow public endpoints BEFORE any authenticated() calls
.requestMatchers("/athlete/create", "/", "/public").permitAll() .requestMatchers("/athlete/create", "/", "/public").permitAll()
.requestMatchers("/coach/**").permitAll() .requestMatchers("/coach/**").hasRole("coach")
// 3. Authenticated endpoints
.requestMatchers("/users/sync").authenticated()
.requestMatchers("/admin/**").hasRole("admin") .requestMatchers("/admin/**").hasRole("admin")
.requestMatchers("/user/**").hasRole("user") .requestMatchers("/athlete/**").hasRole("athlete")
.anyRequest().authenticated()) .anyRequest().authenticated())
.oauth2ResourceServer(oauth2 -> oauth2 .oauth2ResourceServer(oauth2 -> oauth2
.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtToken -> { .jwt(jwt -> jwt.jwtAuthenticationConverter(jwtToken -> {