首页 > 解决方案 > Open Distro Elasticsearch - 使用 JWT 对 Kibana 进行身份验证

问题描述

我可以使用基本身份验证(使用内部用户数据库)运行开放发行版,现在我需要使用 JWT 令牌对 Kibana 仪表板进行身份验证。

弹性搜索配置:

     basic_internal_auth_domain:
        http_enabled: false
        transport_enabled: true
        order: 4
        http_authenticator:
          type: basic
          challenge: true
        authentication_backend:
          type: intern
      proxy_auth_domain:
        http_enabled: false
        transport_enabled: false
        order: 3
        http_authenticator:
          type: proxy
          challenge: false
          config:
            user_header: "x-proxy-user"
            roles_header: "x-proxy-roles"
        authentication_backend:
          type: noop
      jwt_auth_domain:
        enabled: true
        http_enabled: true
        transport_enabled: true
        order: 0
        http_authenticator:
          type: jwt
          challenge: false
          config:
            signing_key: "EdzdXd5weiuSVFyddfjhjhfjjchJGRrZmpkayZPUA=="
            jwt_header: "Authorization"
            jwt_url_parameter: "token"
            roles_key: "roles"
            subject_key: "sub"
        authentication_backend:
          type: noop

Kibana 配置:

server.name: kibana
server.port: 5601
server.host: "127.0.0.1"

elasticsearch.url: https://127.0.0.1:9200
elasticsearch.ssl.verificationMode: none
elasticsearch.username: kibanaserver
elasticsearch.password: kibanaserver
elasticsearch.requestHeadersWhitelist: ["securitytenant","Authorization"]

opendistro_security.auth.type: "jwt"
opendistro_security.jwt.url_param: token

opendistro_security.multitenancy.enabled: true
opendistro_security.multitenancy.tenants.preferred: ["Private", "Global"]
opendistro_security.readonly_mode.roles: ["kibana_read_only"]

在此之后,当我打开http://localhost:5601?token=dfkhdfjdfhdjfhdhfkhdjfhjdhfjdhffdjhfdjhf时,身份验证失败,elasticsearch 日志显示此消息 -

[caoshHTTPBasicAuthenticator] [node-1] 没有“基本授权”标头,发送 401 和“WWW-Authenticate Basic”

我已经彻底遵循了文档,但现在互联网上的材料很少,我猜大多数人仍处于 POC 阶段。有什么建议么?

标签: elasticsearchjwtkibanaelasticsearch-opendistro

解决方案


那些正在寻找答案的人 - 我的 JWT 令牌是错误的,请确保根据您的服务器时间而不是您的本地时间配置“iat”、“nbf”和“exp”。


推荐阅读