• This repository has been archived on 04/Mar/2019
  • Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language
    Java
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HTTP Basic Authentication for Elasticsearch (Discontinued)

IMPORTANT NOTICE: This project is currently not supported. We accept pull requests, but we're not doing any feature development/bug fixing

For alternatives, see Search Guard.

Build Status

IMPORTANT NOTICE: versions 1.0.4 is insecure and should not be used. They have a bug that allows an attacker to get ip authentication by setting its ip on the 'Host' header.

HTTP Basic / Ip auth for ElasticSearch

This plugin provides an extension of ElasticSearchs HTTP Transport module to enable HTTP basic authentication and/or Ip based authentication.

Requesting / does not request authentication to simplify health check configuration.

There is no way to configure this on a per index basis.

Version Mapping

Http Basic Plugin elasticsearch
v1.5.1(master) 1.5.1, 1.5.2, 1.6.0, 1.7.0
v1.5.0 1.5.0
v1.4.0 1.4.0
v1.3.0 1.3.0
v1.2.0 1.2.0
1.1.0 1.0.0
1.0.4 0.90.7

Installation

Download the desired version from https://github.com/Asquera/elasticsearch-http-basic/releases and copy it to plugins/http-basic.

Configuration

Once the plugin is installed it can be configured in the elasticsearch modules configuration file. See the elasticserach directory layout information for more information about the default paths of an ES installation.

Setting key Default value Notes
http.basic.enabled true true disables the default ES HTTP Transport module
http.basic.user "admin"
http.basic.password "admin_pw"
http.basic.ipwhitelist ["localhost", "127.0.0.1"] If set to false no ip will be whitelisted. Uses Host Name Resolution from java.net.InetAddress
http.basic.trusted_proxy_chains [] Set an array of trusted proxies ips chains
http.basic.log false enables plugin logging to ES log. Unauthenticated requests are always logged.
http.basic.xforward "" most common is X-Forwarded-For

Be aware that the password is stored in plain text.

Http basic authentication

see this article

Ip based authentication

A client is Ip authenticated iff its request is trusted and its ip is whitelisted. A Request from a client connected directly (direct client) is by definition trusted. Its ip is the request ip. A Request form a client connected via proxies (remote client) is trusted iff there is a tail subchain of the request chain that matches a tail subchain of the trusted proxy chains.

A tail subchain of a chain "A,B,C" is a subchain that matches it by the end. Example: the 3 tail subchains of the ip chain A,B,C are:

(pseudo code) tailSubchains("A,B,C") --> ["A,B,C", "B,C", "C"]

The request chain of a remote client is obtained following these steps:

  • read the request's xforward configured header field.
  • remove the xforwarded defined client's ip (first listed ip as defined by X-Forwarded-For) from it.
  • append the request ip to it.

The ip chain of a remote client is the ip previous to the longest trusted tail subchain .Is the ip used to check against the whitelist.

Request chain checks

Having the following configuration:

http.basic.xforward = 'X-Forwarded-For'
http.basic.trusted_proxy_chains = ["B,C", "Z"]

Trusted cases:

  • A remote client with ip A connects to [server] via proxies with ips B and C. X-Forwarded-For header has "A,B", removing the client's ip "A" and adding the request ip C, the resulting chain B,C matches a trusted tail subchain. Client's ip is A.

      [A] --> B --> C --> [server]
    
  • A remote client with ip A connects to [server] via proxies with ips R, P, B and C. X-Forwarded-For header has "A,R,P,B". Removing the client's ip "A" and adding the request ip C , the resulting chain ** matches a trusted tail subchain. note: in this case "P" is taken as the client's ip, and checked against the white list. Client's ip is P.

      [A] --> R --> P --> B --> C --> [server]
    
  • A remote client with ip A connects to [server] via C. X-Forwarded-For header has A, removing the client's ip A and adding the request ip C, the resulting chain C matches a trusted tail subchain. Client's ip is A.

      [A] --> C --> [server]
    
  • client A connects directly to [server]. X-Forwarded-For header is not set. Client's ip is A.

      [A] --> [server]
    

Untrusted cases:

  • A remote client with ip A connects to [server] via D. X-Forwarded-For header has "A", removing the client's ip "A" and adding the request ip D, the resulting chain D doesn't match any trusted sub ip chain.

      [A] --> D --> [server]
    
  • A remote client with ip X connects to proxy with ip C passing a faked X-Forwarded-For header "R". C will check the IP of the request and add it to the X-Forwarded-For field. the server will receive and X-Forwarded-For header as: "R,X", remove the client's ip "R", add the request ip "C" and finally drop the request, as "X,C" doesn't match the trusted ip.

      [X] -- R --> C --> [server]
    

configuration example

The following code enables plugin logging, sets user and password, sets chain "1.1.1.1,2.2.2.2" as trusted , whitelists ip 3.3.3.3 and defines xforward header as the common 'X-Forwarded-For':

http.basic.log: true
http.basic.user: "some_user"
http.basic.password: "some_password"
http.basic.ipwhitelist: ["3.3.3.3"]
http.basic.xforward: "X-Forwarded-For"
http.basic.trusted_proxy_chains: ["1.1.1.1,2.2.2.2"]

Testing

note: localhost is a whitelisted ip as default. Considering a default configuration with my_username and my_password configured.

Correct credentials

$ curl -v localhost:9200 # works (returns 200) (by default localhost is configured as whitelisted ip)
$ curl -v --user my_username:my_password no_local_host:9200/foo # works (returns 200) (if credentials are set in configuration)

Wrong credentials

$ curl -v --user my_username:wrong_password no_local_host:9200/    # health check, returns 200 with  "{\"OK\":{}}" although Unauthorized
$ curl -v --user my_username:password no_local_host:9200/foo       # returns 401

Development

Testing

Maven is configured to run the unit and integration tests. This plugin makes use of ES Integration Tests

We can configure at the cli the version of ES we want to test against:

mvn -Delasticsearch.version=1.5.2 -Dtests.security.manager=false test runs all tests mvn -Delasticsearch.version=1.5.2 -Dtests.security.manager=false integration runs integration tests only

Packaging

mvn -Delasticsearch.version=1.5.2 -Dtests.security.manager=false package packages the plugin in a jar file

Issues

Please file your issue here: https://github.com/Asquera/elasticsearch-http-basic/issues

More Repositories

1

raspberry-devbox

a vagrant devbox for development with rasperry pi
109
star
2

warden-hmac-authentication

A tiny HMAC implementation and warden strategy
Ruby
56
star
3

padrino-rpm

New Relic Instrumentations for the Padrino framework
Ruby
17
star
4

elasticsearch-rake-tasks

a collection of useful tasks to support a lean elasticsearch development workflow
Ruby
13
star
5

eson

A modular and basic ElasticSearch client
Ruby
11
star
6

vagrant-riak-cluster

Puppet
8
star
7

varnish-metric

A varnish module for sending statsd metrics.
C
6
star
8

puppet-recipes

Eine Sammlung von hilfreichen Puppet-Recipes, primรคr fรผr die Verwendung mit Vagrant-Boxen
Ruby
6
star
9

elasticsearch-jruby-river

A generic river that runs ruby scripts
Java
5
star
10

varnish-newrelic

Shell
4
star
11

vagrant-tomcat-box

Puppet
3
star
12

elasticsearch-workshop-book

Elasticsearch training material & examples as a mdbook
3
star
13

sinatra-views

View modules for Sinatra
Ruby
3
star
14

html-classes

Sample Files for a small HTML/CSS-Class
2
star
15

mrs_wilson

And I'm a good servant; I'm better than good, I'm the best; I'm the perfect servant.
Ruby
2
star
16

riot-dm-transactional

Wraps riot tests in a Datamapper Transaction
2
star
17

safe-download

A sinatra-based download server that can stand in as a small CDN server
Ruby
2
star
18

psych-inherit-file

A YAML handler for psych that allows to inherit from shared files
Ruby
2
star
19

htty-rack

htty, but speaking through rack
Ruby
2
star
20

elasticsearch-node

A library to control elasticsearch nodes
Ruby
2
star
21

net-http-instrumentation

provides some instrumentation for net/http.
Ruby
2
star
22

goto-async-rust-2018

Async server programming
CSS
2
star
23

eson-dsl

An implementation of the ElasticSearch Query DSL
Ruby
1
star
24

vagrant-puppet-library

a vagrant plugin that spins up puppet-library before the provisioning step
Ruby
1
star
25

dpkg-deb-ruby-wrapper

A ruby wrapper around dpkg-deb
Ruby
1
star
26

padrino-talk

padrino talk
Ruby
1
star
27

eson-couch_potato

Eson integration for couch_potato. Use elasticsearch, have fun!
Ruby
1
star
28

elk-example

ELK stack VM with Vagrant and Puppet including the Movies100k rating dataset by Movielens.
Ruby
1
star
29

incredible-machines

a collection of templates for virtual machines of all kinds
1
star
30

g2o_warden

A warden strategy for akamai G2O requests
JavaScript
1
star
31

bigcouch-ebuild

Provides an ebuild to build bigcouch on gentoo
1
star
32

vagrant-patches

A patchset collection for vagrant
Ruby
1
star