Code Monkey home page Code Monkey logo

esauthplugin's Introduction

说明

  • elasticsearch权限插件
  • 功能列表
    • 用户名、密码校验
    • 请求ip校验

安装

  • 下载源码
  • 打包: mvn clean package
  • $ES_HOME/plugins下新建目录auth,将产出target/release/xxx.zip的压缩文件解压到$ES_HOME/plugins/auth

配置

  • 复制插件根目录下的auth.conf文件到es的配置目录($ES_HOME/conf/auth.conf),如果没有这个配置文件,安装插件后es将会启动失败

  • 配置项参数含义

    参数 默认值 说明
    open_auth false 是否开启验证
    username admin 配置的用户名
    password admin 配置的密码
    open_ip_auth false 是否开启ip授权
    ip_auth_list ["127.0.0.1"] ip授权名单

使用

  • 开启授权后,请求es的rest接口,将返回如下json,http状态码是403

    $ curl -XGET 'localhost:9200?pretty'
    {
      "status" : "FORBIDDEN",
      "message" : "You are not login"
    }
    
  • 开启授权后,如果需要正常请求到结果,需要将用户名(username)和密码(password)拼接成 username:password,然后再进行base64编码得到字符串auth,再以参数形式传入进去。

    $ curl -XGET 'localhost:9200?auth=YWRtaW46YWRtaW4=&pretty'
    {
      "name" : "node-test",
      "cluster_name" : "es-docker",
      "version" : {
        "number" : "2.3.2",
        "build_hash" : "b9e4a6acad4008027e4038f6abed7f7dba346f94",
        "build_timestamp" : "2016-04-21T16:03:47Z",
        "build_snapshot" : false,
        "lucene_version" : "5.5.0"
      },
      "tagline" : "You Know, for Search"
    }
    

    其中 YWRtaW46YWRtaW4=base64_encode("admin:admin") 的结果

  • 配置文件支持热加载,如果修改配置后,需要让配置文件生效,可以请求/_auth/config_reload去重载配置文件。

    // 热更新配置
    $ curl -XGET 'localhost:9200/_auth/config_reload?pretty'
    {
      "status" : "OK",
      "message" : "config reload success"
    }
    // 读取当前配置
    $ curl -XGET 'localhost:9200/_auth/config_show?pretty'
    {
      "open_auth" : false,
      "username" : "admin",
      "password" : "admin",
      "open_ip_auth" : false,
      "ip_auth_list" : [ "127.0.0.1" ]
    }
    

esauthplugin's People

Contributors

ghostboyzone avatar

Watchers

James Cloos 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.