mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
feat: 完善开放接口
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 开放接口 Scope 校验(仅用于 /open/** Controller)
|
||||
* 开放接口 Scope 校验(仅用于 /api/open/** Controller)
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class SecurityConfig {
|
||||
.authenticationEntryPoint(new CustomAuthenticationEntryPoint())
|
||||
.accessDeniedHandler(committedSafeAccessDeniedHandler()))
|
||||
// 两个自定义 Filter 均锚定到 UsernamePasswordAuthenticationFilter;
|
||||
// 后注册的执行更靠前,故先注册 JWT、再注册 ApiKey,保证 /open/** 先走 ApiKey
|
||||
// 后注册的执行更靠前,故先注册 JWT、再注册 ApiKey,保证 /api/open/** 先走 ApiKey
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.addFilterBefore(apiKeyAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
if (uri == null) {
|
||||
return false;
|
||||
}
|
||||
return uri.startsWith("/open/")
|
||||
return uri.startsWith("/api/open/")
|
||||
|| uri.startsWith("/api/channel/pdd/auth/callback")
|
||||
|| uri.startsWith("/channel/pdd/auth/callback");
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,13 +25,13 @@ import java.util.Set;
|
||||
import top.xyquan.ecomdmbbackend.modules.open.key.util.OpenApiKeyHashUtils;
|
||||
|
||||
/**
|
||||
* API Key 认证过滤器(仅处理 /open/** 路径)
|
||||
* API Key 认证过滤器(仅处理 /api/open/** 路径)
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ApiKeyAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
private static final String OPEN_PATH_PREFIX = "/open/";
|
||||
private static final String OPEN_PATH_PREFIX = "/api/open/";
|
||||
|
||||
private final OpenApiKeyService openApiKeyService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
Reference in New Issue
Block a user