fix(file-service): restrict file-serving permitAll to GET requests only
Upload endpoint (POST) was inadvertently matched by the method-less
requestMatchers("/api/file/*") rule. Making it GET-only makes the intent
explicit and ensures upload correctly requires a valid JWT.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
父节点
4e54737e72
当前提交
623656648e
@ -36,12 +36,12 @@ public class SecurityConfig {
|
|||||||
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
// Public: serve files by hash and thumbnails
|
// Public: serve files by hash and thumbnails (GET only — upload requires auth)
|
||||||
.requestMatchers("/api/file/*/thumbnail").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/file/*/thumbnail").permitAll()
|
||||||
.requestMatchers("/api/file/*").permitAll()
|
.requestMatchers(HttpMethod.GET, "/api/file/*").permitAll()
|
||||||
// Actuator health & info
|
// Actuator health & info
|
||||||
.requestMatchers("/actuator/**").permitAll()
|
.requestMatchers("/actuator/**").permitAll()
|
||||||
// Upload requires authentication
|
// Everything else (including POST /api/file/upload) requires authentication
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.exceptionHandling(ex -> ex
|
.exceptionHandling(ex -> ex
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户