Add category module and require post category

This commit is contained in:
Tim
2025-06-30 23:07:15 +08:00
parent 4f24934a45
commit 5dd29239c9
10 changed files with 163 additions and 7 deletions

View File

@@ -68,6 +68,9 @@ public class SecurityConfig {
.requestMatchers(HttpMethod.POST, "/api/auth/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/posts/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/comments/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/categories/**").permitAll()
.requestMatchers(HttpMethod.POST, "/api/categories/**").hasAuthority("ADMIN")
.requestMatchers(HttpMethod.DELETE, "/api/categories/**").hasAuthority("ADMIN")
.requestMatchers("/api/admin/**").hasAuthority("ADMIN")
.anyRequest().authenticated()
)
@@ -84,7 +87,7 @@ public class SecurityConfig {
String uri = request.getRequestURI();
boolean publicGet = "GET".equalsIgnoreCase(request.getMethod()) &&
(uri.startsWith("/api/posts") || uri.startsWith("/api/comments"));
(uri.startsWith("/api/posts") || uri.startsWith("/api/comments") || uri.startsWith("/api/categories"));
if (authHeader != null && authHeader.startsWith("Bearer ")) {
String token = authHeader.substring(7);