opendistro

package module
v0.0.0-...-940043e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2020 License: MPL-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

OpenDistro for Elasticsearch Database Secrets Engine

based on the original plugin

This plugin provides unique, short-lived credentials for Elasticsearch using OpenDistro.

Tested with Opendistro Security Plugin 1.6.0 and Vault 1.4.1.

Getting Started

For this plugin to work, you must first install OpenDistro.

Build

To build this plugin simply run

$ go build -o build/vault-plugin-database-opendistro ./cmd/vault-plugin-database-opendistro
Configure

Enable database secrets engine

$ vault secrets enable -path=example database

Configure which roles can be used with

$ vault write example/config/opendistro \
    plugin_name="vault-plugin-database-opendistro" \
    allowed_roles="internally-defined-role,externally-defined-role" \
    username=admin \
    password=admin \
    url=http://localhost:9200 \
    insecure=true

Define external role which will be used when new users a generated

vault write example/roles/externally-defined-role \
  db_name=opendistro \
  creation_statements='{ 
                          "opendistro_role_permissions": { 
                            "index_permissions": [ 
                              { 
                                "index_patterns": [ 
                                  "test-index-*" 
                                ], 
                                "allowed_actions": [ 
                                  "unlimited" 
                                ] 
                              } 
                            ] 
                          } 
                        }' \
  default_ttl="10m" \
  max_ttl="30m"
Generate User

Read the cred by previously defined role

$ vault read example/creds/externally-defined-role
  Key                Value
  ---                -----
  lease_id           example/creds/externally-defined-role/w0MfpmzZ0jkWAyS1rnOvICSg
  lease_duration     10m
  lease_renewable    true
  password           A1a-9TzAGce3tbyePZvZ
  username           v_token_externally-defi_KxTRtdypZt5z4Dpy9AWW_1572991043

Try to add a new document with the new user and pass

$ curl -s -k -X POST http://localhost:9200/test-index-1/_doc \
      -H "Content-Type: application/json" \
      -u v_token_externally-defi_KxTRtdypZt5z4Dpy9AWW_1572991043:A1a-9TzAGce3tbyePZvZ \ 
      -d '{
            "name":"test"
          }' | jq

Expected result looks like this

{
  "_index":"test-index-1",
  "_type":"_doc",
  "_id":"__2SPW4Bxqko3nrD2tZW",
  "_version":1,
  "result":"created",
  "_shards":{
    "total":2,
    "successful":2,
    "failed":0
  },
  "_seq_no":3,
  "_primary_term":14
}

Development

The Vault plugin system is documented on the Vault documentation site.

You will need to define a plugin directory using the plugin_directory configuration directive, then place the vault-plugin-database-opendistro executable generated above in the directory.

Register the plugin using

vault write sys/plugins/catalog/vault-plugin-database-opendistro \
    sha256=$(shasum -a 256 vault-plugin-database-opendistro | cut -d " " -f 1) \
    command="vault-plugin-database-opendistro"

Documentation

Overview

This is a vault database plugin for OpenDistro. It is based on the official elasticsearch plugin. See https://github.com/hashicorp/vault-plugin-database-elasticsearch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (interface{}, error)

func Run

func Run(apiTLSConfig *api.TLSConfig) error

Types

type Opendistro

type Opendistro struct {
	// contains filtered or unexported fields
}

func NewOpendistro

func NewOpendistro() *Opendistro

func (*Opendistro) Close

func (o *Opendistro) Close() error

func (*Opendistro) CreateUser

func (o *Opendistro) CreateUser(ctx context.Context, statements dbplugin.Statements, usernameConfig dbplugin.UsernameConfig, _ time.Time) (string, string, error)

func (*Opendistro) GenerateCredentials

func (o *Opendistro) GenerateCredentials(ctx context.Context) (string, error)

GenerateCredentials returns a generated password

func (*Opendistro) Init

func (o *Opendistro) Init(ctx context.Context, config map[string]interface{}, verifyConnection bool) (map[string]interface{}, error)

func (*Opendistro) Initialize

func (o *Opendistro) Initialize(ctx context.Context, config map[string]interface{}, verifyConnection bool) error

func (*Opendistro) RenewUser

func (o *Opendistro) RenewUser(_ context.Context, _ dbplugin.Statements, _ string, _ time.Time) error

func (*Opendistro) RevokeUser

func (o *Opendistro) RevokeUser(ctx context.Context, statements dbplugin.Statements, username string) error

func (*Opendistro) RotateRootCredentials

func (o *Opendistro) RotateRootCredentials(ctx context.Context, _ []string) (map[string]interface{}, error)

func (*Opendistro) SecretValues

func (o *Opendistro) SecretValues() map[string]interface{}

SecretValues is used by some error-sanitizing middleware in Vault that basically replaces the keys in the map with the values given so they're not leaked via error messages.

func (*Opendistro) SetCredentials

func (o *Opendistro) SetCredentials(ctx context.Context, statements dbplugin.Statements, staticConfig dbplugin.StaticUserConfig) (username string, password string, err error)

SetCredentials is used to set the credentials for a database user to a specific username and password. This is not currently supported by the elastic search plugin, but is needed to conform to the dbplugin.Database interface

func (*Opendistro) Type

func (o *Opendistro) Type() (string, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址