mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	 f96f4eebfc
			
		
	
	f96f4eebfc
	
	
	
		
			
			* Mark deprecated plugins as deprecated * Add redaction capability to database plugins * Add x509 client auth * Update vendored files * Add integration test for x509 client auth * Remove redaction logic pending further discussion * Update vendored files * Minor updates from code review * Updated docs with x509 client auth * Roles are required * Disable x509 test because it doesn't work in CircleCI * Add timeouts for container lifetime
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package mongodb
 | |
| 
 | |
| import "go.mongodb.org/mongo-driver/mongo/writeconcern"
 | |
| 
 | |
| type createUserCommand struct {
 | |
| 	Username string        `bson:"createUser"`
 | |
| 	Password string        `bson:"pwd,omitempty"`
 | |
| 	Roles    []interface{} `bson:"roles"`
 | |
| }
 | |
| 
 | |
| type updateUserCommand struct {
 | |
| 	Username string `bson:"updateUser"`
 | |
| 	Password string `bson:"pwd"`
 | |
| }
 | |
| 
 | |
| type dropUserCommand struct {
 | |
| 	Username     string                     `bson:"dropUser"`
 | |
| 	WriteConcern *writeconcern.WriteConcern `bson:"writeConcern"`
 | |
| }
 | |
| 
 | |
| type mongodbRole struct {
 | |
| 	Role string `json:"role" bson:"role"`
 | |
| 	DB   string `json:"db"   bson:"db"`
 | |
| }
 | |
| 
 | |
| type mongodbRoles []mongodbRole
 | |
| 
 | |
| type mongoDBStatement struct {
 | |
| 	DB    string       `json:"db"`
 | |
| 	Roles mongodbRoles `json:"roles"`
 | |
| }
 | |
| 
 | |
| // Convert array of role documents like:
 | |
| //
 | |
| // [ { "role": "readWrite" }, { "role": "readWrite", "db": "test" } ]
 | |
| //
 | |
| // into a "standard" MongoDB roles array containing both strings and role documents:
 | |
| //
 | |
| // [ "readWrite", { "role": "readWrite", "db": "test" } ]
 | |
| //
 | |
| // MongoDB's createUser command accepts the latter.
 | |
| func (roles mongodbRoles) toStandardRolesArray() []interface{} {
 | |
| 	var standardRolesArray []interface{}
 | |
| 	for _, role := range roles {
 | |
| 		if role.DB == "" {
 | |
| 			standardRolesArray = append(standardRolesArray, role.Role)
 | |
| 		} else {
 | |
| 			standardRolesArray = append(standardRolesArray, role)
 | |
| 		}
 | |
| 	}
 | |
| 	return standardRolesArray
 | |
| }
 |