Skip to content

Support aliyun mse signature for nacos.#7648

Merged
limingxinleo merged 5 commits intohyperf:masterfrom
Ulyssesyi:master
Feb 1, 2026
Merged

Support aliyun mse signature for nacos.#7648
limingxinleo merged 5 commits intohyperf:masterfrom
Ulyssesyi:master

Conversation

@Ulyssesyi
Copy link
Contributor

feat: Grpc支持阿里云的MSE的鉴权逻辑
fix: ConfigChangeNotifyRequest中传入的json可能没有tenant等key导致了代码异常退出的问题

@huangdijia
Copy link
Member

PR 评审

✅ 优点

  1. 解决实际问题:阿里云 MSE 需要特殊鉴权,之前 Hyperf Nacos 组件不支持
  2. 兼容性好:有 accessKey 走 MSE 鉴权,没有则走原来的 token 逻辑
  3. 防御性编程ConfigChangeNotifyRequest 的空值兜底避免了生产环境崩溃
  4. 代码风格:已通过 PHP CS Fix

⚠️ 建议改进

1. 签名算法可抽离

getMseSignHeaders() 可以考虑放到单独的 MseAuthenticator 类或 trait,便于:

  • 单元测试签名逻辑
  • 复用到其他 MSE 相关场景

2. 缺少单元测试

建议补充测试用例:

public function testGetMseSignHeadersWithTenantAndGroup()
public function testGetMseSignHeadersWithoutTenant()
public function testConfigChangeNotifyRequestWithMissingKeys()

3. Client-AppName 硬编码为空

'Client-AppName' => '',

建议从配置读取,或至少加个注释说明为什么留空。

4. 时间戳精度

$timeStamp = (string) round(microtime(true) * 1000);

这里用 round() 可能导致精度问题,建议用 (int)floor()

$timeStamp = (string) (int) (microtime(true) * 1000);

5. 文档/CHANGELOG

  • 建议在 PR 描述或 CHANGELOG 中说明如何配置 accessKeyaccessSecret

🏁 结论

可以合并,但建议作者:

  1. 补充单元测试(至少覆盖签名逻辑)
  2. 考虑时间戳精度问题
  3. 添加配置示例文档

整体代码质量不错,解决了阿里云 MSE 用户的痛点 👍

@limingxinleo limingxinleo changed the title Nacos的Grpc长链接支持阿里云的MSE鉴权 Support aliyun mse signature for nacos. Feb 1, 2026
@limingxinleo limingxinleo merged commit c06a543 into hyperf:master Feb 1, 2026
76 of 77 checks passed
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

Successfully merging this pull request may close these issues.

3 participants