mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
init
This commit is contained in:
@@ -39,7 +39,7 @@ public class PreValidateFilter extends BaseZuulFilter {
|
|||||||
try {
|
try {
|
||||||
validator.validate(param);
|
validator.validate(param);
|
||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
log.error("签名验证失败,params:{}", param.toJSONString(), e);
|
log.error("验证失败,params:{}", param.toJSONString(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -118,14 +118,17 @@ public class ApiValidator implements Validator {
|
|||||||
protected void checkSign(ApiParam param) {
|
protected void checkSign(ApiParam param) {
|
||||||
String clientSign = param.fetchSign();
|
String clientSign = param.fetchSign();
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isEmpty(param.fetchSign())) {
|
if (StringUtils.isEmpty(clientSign)) {
|
||||||
throw ErrorEnum.ISV_MISSING_SIGNATURE.getErrorMeta().getException(param.fetchNameVersion(), ParamNames.SIGN_NAME);
|
throw ErrorEnum.ISV_MISSING_SIGNATURE.getErrorMeta().getException(param.fetchNameVersion(), ParamNames.SIGN_NAME);
|
||||||
}
|
}
|
||||||
String secret = ApiContext.getApiConfig().getAppSecretManager().getSecret(param.fetchAppKey());
|
ApiConfig apiConfig = ApiContext.getApiConfig();
|
||||||
|
AppSecretManager appSecretManager = apiConfig.getAppSecretManager();
|
||||||
|
// 根据appId获取秘钥
|
||||||
|
String secret = appSecretManager.getSecret(param.fetchAppKey());
|
||||||
if (StringUtils.isEmpty(secret)) {
|
if (StringUtils.isEmpty(secret)) {
|
||||||
throw ErrorEnum.ISV_MISSING_SIGNATURE_CONFIG.getErrorMeta().getException();
|
throw ErrorEnum.ISV_MISSING_SIGNATURE_CONFIG.getErrorMeta().getException();
|
||||||
}
|
}
|
||||||
Signer signer = ApiContext.getApiConfig().getSigner();
|
Signer signer = apiConfig.getSigner();
|
||||||
boolean isRightSign = signer.checkSign(ApiContext.getRequest(), secret);
|
boolean isRightSign = signer.checkSign(ApiContext.getRequest(), secret);
|
||||||
// 错误的sign
|
// 错误的sign
|
||||||
if (!isRightSign) {
|
if (!isRightSign) {
|
||||||
|
Reference in New Issue
Block a user