【问题标题】:OAuth Token API Not Working In Elastic SearchOAuth 令牌 API 在弹性搜索中不起作用
【发布时间】:2020-10-15 21:27:35
【问题描述】:

我是弹性搜索的新手。通过 Java High Level Rest Client 将我的 Spring boot 应用程序与 Elastic search 集成,并且在设置证书和密码后,我通过提供以下属性来启用安全性:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: "http.p12"

我也在 kibana.yaml 中完成了所需的更改,并且可以访问它。 通过 Kibana 尝试以下调用以获取 OAuth 令牌:

   POST /_security/oauth2/token
    {
      "grant_type" : "password",
      "username" : "elastic",
      "password" : "password_for_elastic_super_user"
    }

在 kibana 中执行后出现以下错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "current license is non-compliant for [security tokens]",
        "license.expired.feature" : "security tokens"
      }
    ],
    "type" : "security_exception",
    "reason" : "current license is non-compliant for [security tokens]",
    "license.expired.feature" : "security tokens"
  },
  "status" : 403
}

我也打了GET license API,得到以下回复:

{
  "license" : {
    "status" : "active",
    "uid" : "62b089de-422e-41f0-88c8-9ad76b27cd62",
    "type" : "basic",
    "issue_date" : "2020-06-25T07:17:48.310Z",
    "issue_date_in_millis" : 1593069468310,
    "max_nodes" : 1000,
    "issued_to" : "elasticsearch",
    "issuer" : "elasticsearch",
    "start_date_in_millis" : -1
  }
}

谁能帮忙解决这个问题?

【问题讨论】:

  • 尝试通过邮递员调用一次。添加基本​​身份验证。请在正文中传递grant_type

标签: java spring-boot elasticsearch oauth-2.0 kibana


【解决方案1】:

您使用的是 basic 版本的 elasticsearch,它没有此安全功能(安全令牌)并导致此问题,您可以参考 Elastic subscription 弹性堆栈安全部分下的什么许可证中包含的更多内容.

security tokens 功能在同一订阅页面中提到的基本许可下不可用,并且可从黄金层获得。

上面已从elasticsearch x-pack source code 确认,如图所示,在运行集成测试时会引发此异常,这是production java code,它会为current license is non-compliant for 引发一般异常消息。

如果您想使用security tokens 功能,您必须升级到最低黄金等级。

【讨论】:

  • 感谢您的回答!如何将许可类型更改为基本类型?
  • @DevChauhan 得到它更新我的答案
【解决方案2】:

通过邮递员尝试:​​

  1. 授权:Basic Auth
  2. 正文:grant_type

【讨论】:

  • 感谢您的回答,已尝试但遇到与 Kibana 相同的错误。
  • 你可以尝试设置 xpack.security.enabled: false。配置更改后不要忘记重新启动。
  • 这将破坏安全实施的目的!应该缺少一些东西,这就是为什么会出现此错误。
  • 错误提示 license of Xpack is expired.因此,建议申请免费的基本许可证或禁用 xpack.security。
  • 基本许可证无权使用安全功能。要试用安全性,您需要使用试用许可证
猜你喜欢
  • 2023-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-30
  • 1970-01-01
相关资源
最近更新 更多