Skip to content

迁移微软授权代码流 client_secret 到 PKCE #5575

Open
CiiLu wants to merge 5 commits intoHMCL-dev:mainfrom
CiiLu:pkce
Open

迁移微软授权代码流 client_secret 到 PKCE #5575
CiiLu wants to merge 5 commits intoHMCL-dev:mainfrom
CiiLu:pkce

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Feb 19, 2026

resolves #5566

https://learn.microsoft.com/zh-cn/entra/identity-platform/v2-oauth2-auth-code-flow

请不要在本机应用或单页应用中使用应用程序机密,因为 client_secret 无法可靠地存储在设备上。

兑换授权代码时,公共客户端(包括本机应用程序和单页应用)不得使用机密或证书。

目前建议将参数(code_challenge)用于所有应用程序类型(公共和机密客户端)

需要黄鱼在 entra 进行一些配置

@CiiLu CiiLu changed the title 迁移微软授权代码流到 PKCE 迁移微软授权代码流 client_secret 到 PKCE Feb 19, 2026
@CiiLu CiiLu marked this pull request as ready for review February 19, 2026 14:38
@huanghongxun
Copy link
Collaborator

更新后,Microsoft Auth Server 是如何验证 client 是 HMCL?我看请求参数内只传递 client_id,不再传递 client_secret 了。
看起来生成codeVerifier和应用本身没啥关系?

@CiiLu
Copy link
Contributor Author

CiiLu commented Feb 19, 2026

看起来生成codeVerifier和应用本身没啥关系?

是。

本地应用不能安全保存 client_secret,所以不靠 secret 认证,而是用 PKCE。Authorization Code 会和 code_challenge 绑定,只有能提供匹配 code_verifier 的一方才能换到 token。

这里目的不是用来证明 client 就是 HMCL,而是用来证明当前换 token 的 client 是最初发起请求的 client ,目的是解决 Authorization Code 被截获后被他人兑换的问题。

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.

[Bug] 无法刷新微软账户

2 participants

Comments