Giter VIP home page Giter VIP logo

elasticsearch-readonlyrest-plugin's Introduction

ghit.me Codacy Badge Build Status

Readonly REST Elasticsearch Plugin

Expose the high performance HTTP server embedded in Elasticsearch directly to the public, safely blocking any attempt to delete or modify your data.

In other words... no more proxies! Yay Ponies!

FORK Additional Feature

This fork contains a Index Mapping additional rule which allows replacing one index by another

Use case: In order to share the same dashboard in Kibana between several users to some reduced part of a unique index, we use filtered index. By giving the index accessibility to all users, we can then restricted the queries to use only the filtered index.

The additional index mapping is applied once all authentication check have been succesfully passed. The step takes 2 parameters:

  • source is the initial index found in the request
  • target is the index you want to run the query against

Obviously, the user has to have access to at least the original request index if you want the authentication checks to succeed.

Getting started

1. Install the plugin

Replace the ES version with the one you have:

bin/plugin install https://github.com/sscarduzio/elasticsearch-readonlyrest-plugin/raw/master/download/elasticsearch-readonlyrest-v1.7_es-v2.2.1.zip
2. Configuration

Append either of these snippets to conf/elasticsearch.yml

USE CASE 1: Full access from localhost + RO Access just to catalogue- indices*

readonlyrest:
    enable: true
    response_if_req_forbidden: Sorry, your request is forbidden.
    access_control_rules:

    - name: Accept all requests from localhost
      type: allow
      hosts: [127.0.0.1]
    
    - name: Just certain indices, and read only
      type: allow
      actions: [cluster:*, indices:data/read/*]
      indices: [product_catalogue-*] # index aliases are taken in account!

USE CASE 2: Authenticated users in Kibana (various permission levels)

readonlyrest:
    enable: true
    response_if_req_forbidden: <h1>Forbidden</h1>    
    access_control_rules:

    - name: Salesmen (read only)
      type: allow
      kibana_access: ro
      auth_key: sales:passwd1

    - name: Managers (read only, but can create dashboards)
      type: allow
      kibana_access: ro+
      auth_key: manager:passwd2
    
    - name: Admin (read write)
      type: allow
      kibana_access: rw
      auth_key: admin:passwd3
3. restart elastic search

For other use cases and finer access control have a look at the full list of supported rules

News

2016-02-21 ๐Ÿ†• v1.9.1:

  • kibana_access support access control for Kibana dashboards in "ro|rw|ro+" modes.
  • kibana_indices if you customize the kibana.index property in kibana.yml let us know so kibana_access works as it should.
  • actions rule lets you control what kind of actions are allowed/forbidden. I.e. [cluster:*, indices:data:*]
  • indices rule now supports wildcards i.e. the word logstash-* will match itself, but also logstash-2016-04-02

2016-02-21 ๐Ÿ†• v1.8: indices rule now resolves index aliases.

2016-02-21 ๐Ÿ†• v1.7: real (multi)index isolation is now possible through indices rule (supersedes uri_re).

2016-02-20 ๐Ÿ†• v1.6: show login prompt in browsers if auth_key is configured.

2015-12-19 ๐Ÿ†• v1.5: support for X-Forwarded-For, HTTP Basic Authentication, and X-API-Key.

Download the latest build

Plugin releases for earlier versions of Elasticsearch (may not include all the features) are available in the download folder.

** If you need a build for a specific ES version, open an issue and you'll get it. **

Features

Lightweight security ๐Ÿš€

Other security plugins are replacing the high performance, Netty based, embedded REST API of Elasticsearch with Tomcat, Jetty or other cumbersome XML based JEE madness.

This plugin instead is just a lightweight HTTP request filtering layer.

Less moving parts

Some suggest to spin up a new HTTP proxy (Varnish, NGNix, HAProxy) between ES and clients to prevent malicious access. This is a bad idea for two reasons:

  • You're introducing more moving parts, your architecure gains complexity.
  • Reasoning about security at HTTP level is risky and less granular controlling access at the internal ES protocol level.

The only clean way to do the access control is AFTER ElasticSearch has parsed the queries.

Just set a few rules with this plugin and confidently open for the external world.

A Simpler, flexible access control list (ACL)

Build your ACL from simple building blocks (rules) i.e.:

IP level Rules
  • hosts a list of origin IP addresses or subnets
HTTP level rules
  • api_keys a list of api keys passed in via header X-Api-Key
  • methods a list of HTTP methods
  • accept_x-forwarded-for_header interpret the X-Forwarded-For header as origin host (useful for AWS ELB and other reverse proxies)
  • auth_key HTTP Basic auth.
ElasticSearch level rules
  • indices indices (aliases and wildcards work)
  • actions list of ES actions (e.g. "cluster:" , "indices:data/write/", "indices:data/read*")
ElasticSearh level macro-rules
  • kibana_access captures the read-only, read-only + new visualizations/dashboards, read-write use cases of Kibana.

See the (full list of supported rules)[Supported-Rules] for more info on how to use them.

Custom response body

Optionally provide a string to be returned as the body of 403 (FORBIDDEN) HTTP response. If not provided, the descriptive "name" field of the matched block will be shown (good for debug!).

Extra

History

This project was incepted in this StackOverflow thread.

Credits

Thanks Ivan Brusic for publishing this guide

elasticsearch-readonlyrest-plugin's People

Contributors

gdepourtales avatar gitter-badger avatar luav avatar mscifo avatar nwolff avatar pciccarese avatar rikatz avatar sscarduzio avatar zeeshanasghar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.