为什么 id_token 通过 url 使用片段标识符而不是查询字符串传递?

why id_token is passed via url with fragment identifier instead query string?

openid 认证后,id_token (jwt) 是通过URI 片段而不是查询字符串传递给客户端的,这使得服务器无法读取。这背后的真正座右铭是什么。这有什么好处

只是出于同样的好奇心并找到了答案:

根据 specs.

Returning the id_token in a fragment reduces the likelihood that the id_token leaks during transport and mitigates the associated risks to the privacy of the user (Resource Owner).

您可以通过添加 response_mode=query 来获取查询字符串,但不推荐这样做。因为那是授权码流程。

片段应该在加载 URL 之前被用户代理(例如浏览器)剥离,这样片段就不会出现在服务器端日志中。

人们应该意识到,浏览器实现的最新变化使上述假设受到质疑,依赖授权码流程可能更安全。