【发布时间】:2017-08-25 20:17:39
【问题描述】:
我有一个使用 ADAL-JS(和 adal-angular)的 angularjs SPA 网络应用程序。 它设置为与我们在 MS Azure 中的公司 AD 进行身份验证。登录流程似乎工作正常,并且 SPA 收到了一个 id_token。
接下来,当用户单击按钮时,SPA 会向我在 AWS API Gateway 上托管的 REST API 发出请求。我在 Authorization: Bearer <id_token> 标头上传递 id_token。
API 网关按预期接收标头,现在必须确定给定令牌是否有效,以允许或拒绝访问。
我有一个示例令牌,它可以在 https://jwt.io/ 上正确解析,但到目前为止我还没有找到我应该用来验证签名的公钥或证书。我看过了:
- https://login.microsoftonline.com/{tenantid}/federationmetadata/2007-06/federationmetadata.xml
- https://login.microsoftonline.com/{tenantId}/discovery/keys
- https://login.microsoftonline.com/common/.well-known/openid-configuration(获取 jwks_uri)
- https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration
- https://login.microsoftonline.com/common/discovery/keys
- https://login.microsoftonline.com/common/discovery/v2.0/keys
我认为我应该使用https://login.microsoftonline.com/common/discovery/keys 中键的 x5c 属性的值来匹配 JWT id_token 中的 Kid 和 x5t 属性(当前为 a3QN0BZS7s4nN-BdrjbF0Y_LdMM,这会导致 x5c 值以“MIIDBTCCAe2gAwIBAgIQY...”开头)。但是,https://jwt.io/ 页面报告“无效签名”(我还尝试使用“-----BEGIN CERTIFICATE-----”和“-----END CERTIFICATE-----”包装密钥值)。
此外,是否有一个(可能是 python)库可以方便验证给定的 id_token,如上述情况(这样我就不必自己去获取签名密钥了?)...我能找到的最好的 (ADAL for python) 似乎没有提供此功能?
【问题讨论】:
-
你见过this
-
嘿@4c74356b41 - 感谢您的链接!可能很方便,但是..我看不到该库中的令牌签名在哪里检查?