如何设置 Kibana SSO(通过 OAuth)?

How to setup Kibana SSO (through OAuth)?

我的公司非常努力地为所有第三方服务保留 SSO。我想让 Kibana 与我们的 Google Apps 帐户一起使用。那可能吗?怎么样?

Kibana 将安全性留给您来实现。我相信 Elastic 的 Shield 产品支持安全插件,但我还没有了解订阅模型,也没有深入研究它。

我处理这个问题的方法是使用 oauth2 proxy application 并使用 nginx 反向代理到 Kibana。

server {
    listen 80;
    server_name kibana.example.org;

    # redirect http->https while we're at it
    rewrite ^ https://$server_name$request_uri? permanent;
}

server {
    # listen for traffic destined for kibana.example.org:443
    listen 443 default ssl;

    server_name  kibana.example.org;
    ssl_certificate /etc/nginx/ssl/cert.crt;
    ssl_certificate_key /etc/nginx/ssl/cert.key.pem;
    add_header Strict-Transport-Security max-age=1209600;

    # for https://kibana.example.org/, send to our oauth2 proxy app
    location / {

        # the oauth2 proxy application i use listens on port :4180
        proxy_pass http://127.0.0.1:4180;
        # preserve our host and ip from the request in case we want to
        # dispatch the request to a named nginx directive
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 15;
        proxy_send_timeout 30;
        proxy_read_timeout 30;
    }
}

请求进入,触发一个 nginx 指令,该指令将请求发送到 ouath 应用程序,后者依次处理 SSO 资源并重定向到服务器本地主机上的侦听 Kibana 实例。它是安全的,因为不能直接连接到 Kibana。

从Elasticsearch、Kibana 5.0开始,shield plugin(安全插件)嵌入x-pack(付费服务)。因此,从 Kibana 5.0 开始,您可以:

这两个插件都可以与基本身份验证一起使用,因此您可以应用像 this one 这样的 Oauth2 代理。一个额外的代理将转发带有 Authorization header 和摘要 base64(username:password)

的请求

x-pack 的 this article 描述了该过程。所以你将拥有:

我在 this repo 中设置了一个 docker-compose 配置,以便将 searchguard 或 x-pack 与 Kibana/Elasticsearch 6.1.1 一起使用: