mongodb

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MPL-2.0 Imports: 22 Imported by: 67

README

MongoDB Tests

The test TestInit_clientTLS cannot be run within CircleCI in its current form. This is because it's not possible to use volume mounting with the docker executor.

Because of this, the test is skipped. Running this locally shouldn't present any issues as long as you have docker set up to allow volume mounting from this directory:

go test -v -run Init_clientTLS

This may be able to be fixed if we mess with the entrypoint or the command arguments.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (interface{}, error)

New returns a new MongoDB instance

func Run

func Run(apiTLSConfig *api.TLSConfig) error

Run instantiates a MongoDB object, and runs the RPC server for the plugin

Types

type MongoDB

type MongoDB struct {
	credsutil.CredentialsProducer
	// contains filtered or unexported fields
}

MongoDB is an implementation of Database interface

func (MongoDB) Close added in v0.10.0

func (c MongoDB) Close() error

Close terminates the database connection.

func (MongoDB) Connection added in v0.10.0

func (c MongoDB) Connection(ctx context.Context) (interface{}, error)

Connection creates or returns an existing a database connection. If the session fails on a ping check, the session will be closed and then re-created. This method does not lock the mutex and it is intended that this is the callers responsibility.

func (*MongoDB) CreateUser

func (m *MongoDB) CreateUser(ctx context.Context, statements dbplugin.Statements, usernameConfig dbplugin.UsernameConfig, expiration time.Time) (username string, password string, err error)

CreateUser generates the username/password on the underlying secret backend as instructed by the CreationStatement provided. The creation statement is a JSON blob that has a db value, and an array of roles that accepts a role, and an optional db value pair. This array will be normalized the format specified in the mongoDB docs: https://docs.mongodb.com/manual/reference/command/createUser/#dbcmd.createUser

JSON Example:

{ "db": "admin", "roles": [{ "role": "readWrite" }, {"role": "read", "db": "foo"}] }

func (MongoDB) Init added in v0.10.0

func (c MongoDB) Init(ctx context.Context, conf map[string]interface{}, verifyConnection bool) (map[string]interface{}, error)

Initialize parses connection configuration.

func (MongoDB) Initialize added in v0.10.0

func (c MongoDB) Initialize(ctx context.Context, conf map[string]interface{}, verifyConnection bool) error

func (*MongoDB) RenewUser

func (m *MongoDB) RenewUser(ctx context.Context, statements dbplugin.Statements, username string, expiration time.Time) error

RenewUser is not supported on MongoDB, so this is a no-op.

func (*MongoDB) RevokeUser

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

RevokeUser drops the specified user from the authentication database. If none is provided in the revocation statement, the default "admin" authentication database will be assumed.

func (*MongoDB) RotateRootCredentials added in v0.10.0

func (m *MongoDB) RotateRootCredentials(ctx context.Context, statements []string) (map[string]interface{}, error)

RotateRootCredentials in MongoDB

func (*MongoDB) SetCredentials added in v1.2.0

func (m *MongoDB) SetCredentials(ctx context.Context, statements dbplugin.Statements, staticUser dbplugin.StaticUserConfig) (username, password string, err error)

SetCredentials uses provided information to set/create a user in the database. Unlike CreateUser, this method requires a username be provided and uses the name given, instead of generating a name. This is used for creating and setting the password of static accounts, as well as rolling back passwords in the database in the event an updated database fails to save in Vault's storage.

func (*MongoDB) Type

func (m *MongoDB) Type() (string, error)

Type returns the TypeName for this backend

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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