2018-05-29 02:13:23 +03:00
# esFrontLine
2013-06-10 17:40:03 +04:00
2018-05-25 14:47:55 +03:00
Limit restful requests to backend ElasticSearch cluster: Queries for the public,
2013-06-12 19:45:49 +04:00
2018-05-29 02:13:23 +03:00
## Requirements
2013-06-12 19:45:49 +04:00
2018-05-25 14:47:55 +03:00
* Python 2.7 or 3.6.2+
2013-10-25 22:25:44 +04:00
* An ElasticSearch cluster to forward queries to
2013-06-12 19:45:49 +04:00
2018-05-29 02:13:23 +03:00
## Install
2013-06-12 19:45:49 +04:00
2013-10-25 22:25:44 +04:00
I will assume you have Python installed (if not, here are [Windows7 instructions ](https://github.com/klahnakoski/pyLibrary#windows-7-install-instructions- ))
2013-06-12 19:45:49 +04:00
2013-11-12 17:28:34 +04:00
pip install esFrontLine
2013-06-12 19:45:49 +04:00
2018-05-29 02:13:23 +03:00
## Setup
2013-06-12 19:45:49 +04:00
2013-11-12 17:28:34 +04:00
You must write your own setting.json file with the following properties set:
2013-06-12 19:45:49 +04:00
2013-11-12 17:28:34 +04:00
* **elasticsearch** - (Array of) ElasticSearch nodes
* **elasticsearch.host** - URL of the ElasticSearch node that will accept query requests
2013-10-25 22:25:44 +04:00
* **elasticsearch.port** - port for ES (default = 9200)
2013-10-26 00:10:11 +04:00
* **flask** - flask.run() parameters (default port = 5000)
2013-11-27 07:40:39 +04:00
* **whitelist** - list of indexes that are allowed
2018-05-21 12:50:27 +03:00
* **users** - list of allowed HAWK users, with their linked resources
2018-05-25 14:47:55 +03:00
* **users.resources** - list of indexes the user is allowed
* **users.hawk** - object of [Hawk credentials ](https://github.com/hueniverse/hawk/blob/master/README.md )
* **users.hawk.id** - any human readable name to identify the user or application
2018-05-28 00:31:09 +03:00
* **users.hawk.key** - the secret value held by both endpoints and not shared with anyone
2018-05-25 14:47:55 +03:00
* **users.hawk.algorithm**: always "sha256" for now
2018-05-28 00:31:09 +03:00
* **debug** - for debugging
2018-05-21 12:50:27 +03:00
2013-10-25 22:25:44 +04:00
Here is an example of my ```settings.json``` file
{
2013-10-26 00:06:11 +04:00
"elasticsearch":[{
"host":"http://elasticsearch4.metrics.scl3.mozilla.com",
"port":9200
},{
"host":"http://elasticsearch5.metrics.scl3.mozilla.com",
"port":9200
},{
"host":"http://elasticsearch7.metrics.scl3.mozilla.com",
"port":9200
},{
2013-10-25 22:25:44 +04:00
"host":"http://elasticsearch8.metrics.scl3.mozilla.com",
"port":9200
2013-10-26 00:06:11 +04:00
}],
2013-10-25 22:25:44 +04:00
"flask":{
"host":"0.0.0.0",
"port":9292,
"debug":false,
"threaded":true,
"processes":1
},
2018-05-21 12:50:27 +03:00
"users": [
{
"hawk": {
"id": "kyle@example.com",
"key": "secret",
"algorithm": "sha256"
},
"resources": [
"testing"
]
}
],
2013-11-27 07:40:39 +04:00
"whitelist":["bugs", "org_chart", "bug_summary", "reviews"],
2013-10-25 22:25:44 +04:00
"debug":{
"log":[{
2013-11-27 07:40:39 +04:00
"filename": "./tests/results/logs/app.log",
2013-10-25 22:25:44 +04:00
"maxBytes": 10000000,
"backupCount": 200,
"encoding": "utf8"
},{
"stream":"sys.stdout"
}]
}
2013-06-12 19:45:49 +04:00
2013-10-26 00:06:11 +04:00
}
2013-11-27 07:40:39 +04:00
2018-05-29 02:13:23 +03:00
## Execution
2013-06-12 19:45:49 +04:00
2013-10-25 22:25:44 +04:00
python app.py --settings-file < path_to_file_with_JSON_settings >
2013-06-12 19:45:49 +04:00
2018-05-29 02:13:23 +03:00
## Code Source
2014-08-08 23:11:29 +04:00
[https://github.com/klahnakoski/esFrontLine ](https://github.com/klahnakoski/esFrontLine )