Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

卡片消息回调代码有问题,设置了密码和token之后配置不了,同样的密码和token,事件回调可以通过验证,卡片订阅不能通过验证,事件回调的地址放到卡片订阅也可以通过。 #116

Open
curryhcy opened this issue Feb 29, 2024 · 1 comment

Comments

@curryhcy
Copy link

如题。我们在使用事件回调和卡片消息回调时同样的key和token,一个能通过校验,一个不能。通过排查,发现两个方法SDK的签名验证逻辑的代码不一样,一个用的是key,一个用的token

` private boolean verifySign(EventReq eventReq) throws NoSuchAlgorithmException {
if (Strings.isEmpty(verificationToken)) {
return true;
}

    String cipherEventJsonStr = new String(eventReq.getBody(), StandardCharsets.UTF_8);
    String timestamp, nonce, sourceSign, targetSign;
    timestamp = eventReq.getHeaderFirstValue(Constants.X_LARK_REQUEST_TIMESTAMP);
    nonce = eventReq.getHeaderFirstValue(Constants.X_LARK_REQUEST_NONCE);
    sourceSign = eventReq.getHeaderFirstValue(Constants.X_LARK_SIGNATURE);
    targetSign = calculateSignature(timestamp, nonce, verificationToken, cipherEventJsonStr);
    return targetSign.equals(sourceSign);
}`

`private boolean verifySign(EventReq eventReq) throws NoSuchAlgorithmException {
if (Strings.isEmpty(encryptKey)) {
return true;
}

    String cipherEventJsonStr = new String(eventReq.getBody(), StandardCharsets.UTF_8);
    String timestamp, nonce, sourceSign, targetSign;
    timestamp = eventReq.getHeaderFirstValue(Constants.X_LARK_REQUEST_TIMESTAMP);
    nonce = eventReq.getHeaderFirstValue(Constants.X_LARK_REQUEST_NONCE);
    sourceSign = eventReq.getHeaderFirstValue(Constants.X_LARK_SIGNATURE);
    targetSign = calculateSignature(timestamp, nonce, encryptKey, cipherEventJsonStr);
    return targetSign.equals(sourceSign);
}`

使用key的可以通过校验,使用token的不能通过。我理解两个事件应该是一样的处理鉴权的逻辑,有人能帮忙看看吗?

@czk997
Copy link

czk997 commented Apr 19, 2024

我也遇到类似问题,通过订阅旧版本回调解决了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants