【问题标题】:What's the right way to call Introspect endpoint in Microsoft IdentityServer 4在 Microsoft IdentityServer4 中调用 Introspection 端点的正确方法是什么
【发布时间】:2020-10-21 22:45:00
【问题描述】:

我可以使用邮递员从 Microsoft Identity Server 4 获取访问令牌。

这是回复:

现在我想使用自省端点对令牌进行身份验证,但返回的是 401 unhautorized,可能是在自省端点的请求中丢失了一些数据?

【问题讨论】:

标签: identityserver4


【解决方案1】:

要在 Postman 中访问令牌自省 enpoint,我使用:

  • POST 到 https://localhost:6001/connect/introspect
  • 添加授权标头,其值为“Basic cGF5bWVudDpteWFwaXNlY3JldA==”。其中秘密是 apiname/秘密。在我的情况下,它是付款和 myapisecret 作为密码。
  • 添加正文 x-www-form-urlencoded,键名为 token,值是我的访问令牌。

应该就是这样了。

【讨论】:

  • 是的,使用 demo.identityserver.io 我可以验证令牌,但是在我的本地身份服务器上使用相同的过程我得到 401 unhautorized。这是 IS 日志:[17:29:09 调试] IdentityServer4.Validation.HashedSharedSecretValidator 没有为客户端配置共享密钥。 [17:29:09 调试] IdentityServer4.Validation.SecretValidator 秘密验证器无法验证秘密 [17:29:09 错误] IdentityServer4.Validation.ApiSecretValidator API 验证失败。 [17:29:09 错误] IdentityServer4.Endpoints.IntrospectionEndpoint API 未经授权调用自省端点。中止。
  • 您是否在 ApiResource 中设置了 ApiSecrets?您可以使用 APIResource 名称和机密来针对令牌自省端点创建基本身份验证。
  • 是的,我解决了它,但没有关于它的文档,我不得不在表 ApiSecrets 中添加一条记录(我从 m$ 示例开始,其中配置存储到 sql server 数据库中)。要直接格式化秘密需要使用 IdentityServer 程序集的类 Secret 编写一些代码行。我也想知道该字符串是否可以解密。 K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=
  • 秘密在 IdentityServer 中被散列,所以应该很难暴力破解。但是授权头字符串当然是不安全的,但这并不是那么重要。
猜你喜欢
  • 1970-01-01
  • 2018-03-30
  • 2020-11-05
  • 2011-11-19
  • 1970-01-01
  • 2017-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多