mongodb

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrNotOK    = errors.New("not ok")

	AppName = "terraform-provider-mongodb-driver"
)

Functions

This section is empty.

Types

type Client

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

func New

func New(uri string, cred Credentials) *Client

func (*Client) CreateDBUser

func (c *Client) CreateDBUser(ctx context.Context, dbName string, newUser NewUser) (User, error)

func (*Client) DeleteDBUser

func (c *Client) DeleteDBUser(ctx context.Context, dbName, userName string) error

func (*Client) GetDBUser

func (c *Client) GetDBUser(ctx context.Context, dbName, userName string) (User, error)

func (*Client) ListAllUsers

func (c *Client) ListAllUsers(ctx context.Context, filter any) ([]User, error)

func (*Client) ListDBUsers

func (c *Client) ListDBUsers(ctx context.Context, dbName string, filter any) ([]User, error)

func (*Client) UpdateDBUser

func (c *Client) UpdateDBUser(ctx context.Context, dbName string, update UpdateUser) (User, error)

type CommandResponse

type CommandResponse struct {
	OK            int       `bson:"ok"`
	OperationTime time.Time `bson:"operationTime"`
}

type Credentials

type Credentials struct {
	Username string
	Password string
}

type Mechanism

type Mechanism string

Mechanism is the mechanism for user authentication.

[https://www.mongodb.com/docs/manual/reference/parameters/#mongodb-parameter-param.authenticationMechanisms]

const (
	// MechanismSCRAMSHA1 is the SCRAM mechanism for creating SCRAM user credentials.
	//
	// RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.
	//
	// - Uses the SHA-1 hashing function.
	//
	// [https://www.mongodb.com/docs/manual/core/security-scram/#std-label-authentication-scram-sha-1]
	MechanismSCRAMSHA1 Mechanism = "SCRAM-SHA-1"

	// MechanismSCRAMSHA256 is the SCRAM mechanism for creating SCRAM user credentials.
	//
	// RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.
	//
	// - Uses the SHA-256 hashing function.
	// - Requires featureCompatibilityVersion set to 4.0.
	// - Requires digestPassword to be true.
	//
	// [https://www.mongodb.com/docs/manual/core/security-scram/#std-label-authentication-scram-sha-256]
	MechanismSCRAMSHA256 Mechanism = "SCRAM-SHA-256"

	// MechanismMONGODBX509 is the mechanism for MongoDB TLS/SSL certificate authentication.
	//
	// [https://www.mongodb.com/docs/manual/core/security-x.509/#std-label-security-auth-x509]
	MechanismMONGODBX509 Mechanism = "MONGODB-X509"

	// MechanismPLAIN is the mechanism for external authentication using LDAP.
	// You can also use PLAIN for authenticating in-database users.
	// PLAIN transmits passwords in plain text.
	// This mechanism is available only in MongoDB Enterprise.
	//
	// [https://www.mongodb.com/docs/manual/core/authentication/#std-label-security-auth-ldap]
	MechanismPLAIN Mechanism = "PLAIN"

	// MechanismGSSAPI is the mechanism for external authentication using Kerberos.
	// This mechanism is available only in MongoDB Enterprise.
	//
	// [https://www.mongodb.com/docs/manual/core/authentication/#std-label-security-auth-kerberos]
	MechanismGSSAPI Mechanism = "GSSAPI"
)

type NewUser

type NewUser struct {
	User       string            `bson:"createUser"`
	Password   string            `bson:"pwd"`
	CustomData map[string]string `bson:"customData,omitempty"`
	Roles      []RoleRef         `bson:"roles"`
	Mechanisms []Mechanism       `bson:"mechanisms,omitempty"`
}

type RoleDBRef

type RoleDBRef struct {
	Role string `bson:"role"`
	DB   string `bson:"db"`
}

RoleDBRef is a RoleRef that points to a role in a specific database.

type RoleRef

type RoleRef interface {
	// contains filtered or unexported methods
}

type RoleSameDBRef

type RoleSameDBRef string

RoleSameDBRef is a RoleRef that points to a role in the same database.

type UpdateUser

type UpdateUser struct {
	User       string            `bson:"updateUser"`
	Password   string            `bson:"pwd,omitempty"`
	CustomData map[string]string `bson:"customData,omitempty"`
	Roles      []RoleRef         `bson:"roles,omitempty"`
	Mechanisms []Mechanism       `bson:"mechanisms,omitempty"`
}

type User

type User struct {
	ID         string            `bson:"_id"`
	UserID     primitive.Binary  `bson:"userId"`
	User       string            `bson:"user"`
	DB         string            `bson:"db"`
	CustomData map[string]string `bson:"customData"`
	Roles      []RoleDBRef       `bson:"roles"`
	Mechanisms []Mechanism       `bson:"mechanisms"`
}

Jump to

Keyboard shortcuts

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