Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2911: Add machine flow OIDC authentication #1678

Open
wants to merge 66 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
a47681f
GODRIVER-2911: Initial attempted to untie the Gordian not, this will …
pmeredit Jun 11, 2024
279635a
GODRIVER-2911: We're going to have to go this way and implement some …
pmeredit Jun 12, 2024
9170d50
GODRIVER-2911: Ok, not great, but this will work
pmeredit Jun 12, 2024
590662d
GODRIVER-2911: Renaming oidc sasl
pmeredit Jun 12, 2024
171204c
GODRIVER-2911: Implement Operation based private sasl conversation fo…
pmeredit Jun 12, 2024
dbc5699
GODRIVER-2911: Privitize all the oidc sasl api, move AuthConfig up so…
pmeredit Jun 12, 2024
ff73302
GODRIVER-2911: Move things as necessary for authentication registration
pmeredit Jun 12, 2024
0db7c3e
GODRIVER-2911: Let's use a bit better naming
pmeredit Jun 12, 2024
be99139
GODRIVER-2911: Add Reauth to Authenticators
pmeredit Jun 12, 2024
f400d18
GODRIVER-2911: Check point
pmeredit Jun 12, 2024
eed3dd5
GODRIVER-2911: Initial plumbing, the Client Authenticator is going to…
pmeredit Jun 13, 2024
2ee93cc
GODRIVER-2911: Set authenticator in topology
pmeredit Jun 13, 2024
f6def8d
GODRIVER-2911: Set authenticator from Command to Operation
pmeredit Jun 13, 2024
bd5c9f2
GODRIVER-2911: Remove authenticator so we can readd it programmatically
pmeredit Jun 13, 2024
36ba008
GODRIVER-2911: Remove authenticator so we can readd it programmatically
pmeredit Jun 13, 2024
a2a4029
GODRIVER-2911: Remove authenticator so we can readd it programatically
pmeredit Jun 13, 2024
d2c75f1
GODRIVER-2911: Add all that authenticator plumbing programmatically s…
pmeredit Jun 13, 2024
4070d06
GODRIVER-2911: Thread through Authenticator
pmeredit Jun 13, 2024
4a44090
GODRIVER-2911: Move OIDC back to auth package, yay
pmeredit Jun 14, 2024
4ea9b9c
GODRIVER-2911: Move Config = AuthConfig to top of the file
pmeredit Jun 14, 2024
2b5cde6
GODRIVER-2911: Update comment
pmeredit Jun 14, 2024
368cedd
GODRIVER-2911: Some implementation
pmeredit Jun 14, 2024
e00e057
GODRIVER-2911: Add OIDCTokenGenID to Connection interface
pmeredit Jun 14, 2024
1666c6c
GODRIVER-2911: Add OIDCTokenGenID to Connection interface for types i…
pmeredit Jun 14, 2024
d90ee3f
GODRIVER-2911: Actually add the oidc file, whoops
pmeredit Jun 14, 2024
19ed261
GODRIVER-2911: Fix nil pointer error
pmeredit Jun 14, 2024
4112208
GODRIVER-2911: Fix fmt
pmeredit Jun 14, 2024
03c4c08
GODRIVER-2911: Fix build failure
pmeredit Jun 14, 2024
dac0468
GODRIVER-2911: well, that was silly
pmeredit Jun 14, 2024
651af66
GODRIVER-2911: Add licenses and fix comment
pmeredit Jun 14, 2024
6b16e91
GODRIVER-2911: Fix receiver names and remove authenticator field from…
pmeredit Jun 14, 2024
26412ae
GODRIVER-2911: Fix many lints. Linter not running for me locally
pmeredit Jun 14, 2024
98e8cbe
GODRIVER-2911: Fix lints
pmeredit Jun 15, 2024
78fa217
GODRIVER-2911: Fix spelling error
pmeredit Jun 15, 2024
46fa6f3
GODRIVER-2911: Testing checkpoint
pmeredit Jun 18, 2024
c6d23de
GODRIVER-2911: Fix config, fix spec auth
pmeredit Jun 18, 2024
c137399
GODRIVER-2911: Checkpoint
pmeredit Jun 19, 2024
1be9498
GODRIVER-2911: OIDC working
pmeredit Jun 19, 2024
8542f76
GODRIVER-2911: add machine_1_2
pmeredit Jun 19, 2024
286525f
GODRIVER-2911: add machine_1_2, actually helps to call it
pmeredit Jun 19, 2024
4013ccb
GODRIVER-2911: Remove unneeded debugging
pmeredit Jun 19, 2024
83ffaa7
GODRIVER-2911: Add more tests
pmeredit Jun 20, 2024
f33dca7
GODRIVER-2911: Updates
pmeredit Jun 20, 2024
3c00307
GODRIVER-2911: Change to using errors
pmeredit Jun 20, 2024
590a3c8
GODRIVER-2911: Add more tests that do not require fail points
pmeredit Jun 20, 2024
e88ebe7
GODRIVER-2911: See if it fails with 10 tries
pmeredit Jun 20, 2024
58f0f42
GODRIVER-2911: Not sure how to get fail points working
pmeredit Jun 20, 2024
1be1e13
GODRIVER-2911: Appease linter
pmeredit Jun 20, 2024
6e1fd3a
GODRIVER-2911: Appease linter
pmeredit Jun 20, 2024
640907d
GODRIVER-2911: Change 3_3 to use fail on find, add 4_1
pmeredit Jun 21, 2024
4d30705
GODRIVER-2911: Manually create fail points
pmeredit Jun 23, 2024
9dd40c9
GODRIVER-2911: This is working except 3_3 seems to be hanging
pmeredit Jun 23, 2024
b343ebb
GODRIVER-2911: Tests all passing
pmeredit Jun 23, 2024
5240a91
GODRIVER-2911: Appease linter
pmeredit Jun 23, 2024
0cdd7a2
GODRIVER-2911: Remove test func that is unneeded
pmeredit Jun 23, 2024
4613c5f
Update x/mongo/driver/auth/oidc.go
pmeredit Jun 26, 2024
40998b6
SQL-1937: Remove spurious authenticators, move mutex
pmeredit Jun 26, 2024
2d09cc5
SQL-1937: Change Reauth interface
pmeredit Jun 26, 2024
d45c7e4
Update Makefile
pmeredit Jul 1, 2024
ae9c34f
GODRIVER-2911: Apply httpclient patch
pmeredit Jul 1, 2024
1d86914
GODRIVER-2911: Fix races
pmeredit Jul 1, 2024
30ed4c4
GODRIVER-2911: Back out changes to sasl, add comment, remove Println …
pmeredit Jul 2, 2024
519205c
GODRIVER-2911: Move public OIDC configuration types into public, non-…
pmeredit Jul 2, 2024
5f0c68d
GODRIVER-2911: Improve comment
pmeredit Jul 2, 2024
6a3af5a
GODRIVER-2911: Update script comment
pmeredit Jul 3, 2024
7340ddd
GODRIVER-2911: Use conversion functions instead of type redeclarations
pmeredit Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/test/compilecheck/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ replace go.mongodb.org/mongo-driver => ../../../
require go.mongodb.org/mongo-driver v1.11.7

require (
github.com/golang/snappy v0.0.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
19 changes: 9 additions & 10 deletions internal/test/compilecheck/go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
Expand All @@ -17,16 +17,16 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -44,4 +44,3 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
7 changes: 4 additions & 3 deletions mongo/bulk_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera
Database(bw.collection.db.name).Collection(bw.collection.name).
Deployment(bw.collection.client.deployment).Crypt(bw.collection.client.cryptFLE).
ServerAPI(bw.collection.client.serverAPI).Timeout(bw.collection.client.timeout).
Logger(bw.collection.client.logger)
Logger(bw.collection.client.logger).Authenticator(bw.collection.client.authenticator)
if bw.comment != nil {
comment, err := marshalValue(bw.comment, bw.collection.bsonOpts, bw.collection.registry)
if err != nil {
Expand Down Expand Up @@ -256,7 +256,7 @@ func (bw *bulkWrite) runDelete(ctx context.Context, batch bulkWriteBatch) (opera
Database(bw.collection.db.name).Collection(bw.collection.name).
Deployment(bw.collection.client.deployment).Crypt(bw.collection.client.cryptFLE).Hint(hasHint).
ServerAPI(bw.collection.client.serverAPI).Timeout(bw.collection.client.timeout).
Logger(bw.collection.client.logger)
Logger(bw.collection.client.logger).Authenticator(bw.collection.client.authenticator)
if bw.comment != nil {
comment, err := marshalValue(bw.comment, bw.collection.bsonOpts, bw.collection.registry)
if err != nil {
Expand Down Expand Up @@ -387,7 +387,8 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera
Database(bw.collection.db.name).Collection(bw.collection.name).
Deployment(bw.collection.client.deployment).Crypt(bw.collection.client.cryptFLE).Hint(hasHint).
ArrayFilters(hasArrayFilters).ServerAPI(bw.collection.client.serverAPI).
Timeout(bw.collection.client.timeout).Logger(bw.collection.client.logger)
Timeout(bw.collection.client.timeout).Logger(bw.collection.client.logger).
Authenticator(bw.collection.client.authenticator)
if bw.comment != nil {
comment, err := marshalValue(bw.comment, bw.collection.bsonOpts, bw.collection.registry)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion mongo/change_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func newChangeStream(ctx context.Context, config changeStreamConfig, pipeline in
ReadPreference(config.readPreference).ReadConcern(config.readConcern).
Deployment(cs.client.deployment).ClusterClock(cs.client.clock).
CommandMonitor(cs.client.monitor).Session(cs.sess).ServerSelector(cs.selector).Retry(driver.RetryNone).
ServerAPI(cs.client.serverAPI).Crypt(config.crypt).Timeout(cs.client.timeout)
ServerAPI(cs.client.serverAPI).Crypt(config.crypt).Timeout(cs.client.timeout).
Authenticator(cs.client.authenticator)

if cs.options.Collation != nil {
cs.aggregate.Collation(bsoncore.Document(cs.options.Collation.ToDocument()))
Expand Down
15 changes: 13 additions & 2 deletions mongo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"go.mongodb.org/mongo-driver/mongo/writeconcern"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
"go.mongodb.org/mongo-driver/x/mongo/driver"
"go.mongodb.org/mongo-driver/x/mongo/driver/auth"
"go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt"
mcopts "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options"
"go.mongodb.org/mongo-driver/x/mongo/driver/operation"
Expand Down Expand Up @@ -79,6 +80,7 @@ type Client struct {
metadataClientFLE *Client
internalClientFLE *Client
encryptedFieldsMap map[string]interface{}
authenticator driver.Authenticator
}

// Connect creates a new Client and then initializes it using the Connect method. This is equivalent to calling
Expand Down Expand Up @@ -213,7 +215,16 @@ func NewClient(opts ...*options.ClientOptions) (*Client, error) {
return nil, err
}

cfg, err := topology.NewConfig(clientOpt, client.clock)
// Create an authenticator for the client
client.authenticator, err = auth.CreateAuthenticator(clientOpt.Auth.AuthMechanism, &auth.Cred{
Source: clientOpt.Auth.AuthSource,
Username: clientOpt.Auth.Username,
Password: clientOpt.Auth.Password,
PasswordSet: clientOpt.Auth.PasswordSet,
Props: clientOpt.Auth.AuthMechanismProperties,
})

cfg, err := topology.NewConfigWithAuthenticator(clientOpt, client.clock, client.authenticator)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -694,7 +705,7 @@ func (c *Client) ListDatabases(ctx context.Context, filter interface{}, opts ...
op := operation.NewListDatabases(filterDoc).
Session(sess).ReadPreference(c.readPreference).CommandMonitor(c.monitor).
ServerSelector(selector).ClusterClock(c.clock).Database("admin").Deployment(c.deployment).Crypt(c.cryptFLE).
ServerAPI(c.serverAPI).Timeout(c.timeout)
ServerAPI(c.serverAPI).Timeout(c.timeout).Authenticator(c.authenticator)

if ldo.NameOnly != nil {
op = op.NameOnly(*ldo.NameOnly)
Expand Down
29 changes: 17 additions & 12 deletions mongo/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ func (coll *Collection) insert(ctx context.Context, documents []interface{},
ServerSelector(selector).ClusterClock(coll.client.clock).
Database(coll.db.name).Collection(coll.name).
Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).Ordered(true).
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).Logger(coll.client.logger)
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).Logger(coll.client.logger).
Authenticator(coll.client.authenticator)
imo := options.MergeInsertManyOptions(opts...)
if imo.BypassDocumentValidation != nil && *imo.BypassDocumentValidation {
op = op.BypassDocumentValidation(*imo.BypassDocumentValidation)
Expand Down Expand Up @@ -471,7 +472,8 @@ func (coll *Collection) delete(ctx context.Context, filter interface{}, deleteOn
ServerSelector(selector).ClusterClock(coll.client.clock).
Database(coll.db.name).Collection(coll.name).
Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).Ordered(true).
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).Logger(coll.client.logger)
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).Logger(coll.client.logger).
Authenticator(coll.client.authenticator)
if do.Comment != nil {
comment, err := marshalValue(do.Comment, coll.bsonOpts, coll.registry)
if err != nil {
Expand Down Expand Up @@ -588,7 +590,7 @@ func (coll *Collection) updateOrReplace(ctx context.Context, filter bsoncore.Doc
Database(coll.db.name).Collection(coll.name).
Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).Hint(uo.Hint != nil).
ArrayFilters(uo.ArrayFilters != nil).Ordered(true).ServerAPI(coll.client.serverAPI).
Timeout(coll.client.timeout).Logger(coll.client.logger)
Timeout(coll.client.timeout).Logger(coll.client.logger).Authenticator(coll.client.authenticator)
if uo.Let != nil {
let, err := marshal(uo.Let, coll.bsonOpts, coll.registry)
if err != nil {
Expand Down Expand Up @@ -861,7 +863,8 @@ func aggregate(a aggregateParams) (cur *Cursor, err error) {
ServerAPI(a.client.serverAPI).
HasOutputStage(hasOutputStage).
Timeout(a.client.timeout).
MaxTime(ao.MaxTime)
MaxTime(ao.MaxTime).
Authenticator(a.client.authenticator)

// Omit "maxTimeMS" from operations that return a user-managed cursor to
// prevent confusing "cursor not found" errors. To maintain existing
Expand Down Expand Up @@ -992,7 +995,7 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{},
op := operation.NewAggregate(pipelineArr).Session(sess).ReadConcern(rc).ReadPreference(coll.readPreference).
CommandMonitor(coll.client.monitor).ServerSelector(selector).ClusterClock(coll.client.clock).Database(coll.db.name).
Collection(coll.name).Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).ServerAPI(coll.client.serverAPI).
Timeout(coll.client.timeout).MaxTime(countOpts.MaxTime)
Timeout(coll.client.timeout).MaxTime(countOpts.MaxTime).Authenticator(coll.client.authenticator)
if countOpts.Collation != nil {
op.Collation(bsoncore.Document(countOpts.Collation.ToDocument()))
}
Expand Down Expand Up @@ -1077,7 +1080,7 @@ func (coll *Collection) EstimatedDocumentCount(ctx context.Context,
Database(coll.db.name).Collection(coll.name).CommandMonitor(coll.client.monitor).
Deployment(coll.client.deployment).ReadConcern(rc).ReadPreference(coll.readPreference).
ServerSelector(selector).Crypt(coll.client.cryptFLE).ServerAPI(coll.client.serverAPI).
Timeout(coll.client.timeout).MaxTime(co.MaxTime)
Timeout(coll.client.timeout).MaxTime(co.MaxTime).Authenticator(coll.client.authenticator)

if co.Comment != nil {
comment, err := marshalValue(co.Comment, coll.bsonOpts, coll.registry)
Expand Down Expand Up @@ -1144,7 +1147,7 @@ func (coll *Collection) Distinct(ctx context.Context, fieldName string, filter i
Database(coll.db.name).Collection(coll.name).CommandMonitor(coll.client.monitor).
Deployment(coll.client.deployment).ReadConcern(rc).ReadPreference(coll.readPreference).
ServerSelector(selector).Crypt(coll.client.cryptFLE).ServerAPI(coll.client.serverAPI).
Timeout(coll.client.timeout).MaxTime(option.MaxTime)
Timeout(coll.client.timeout).MaxTime(option.MaxTime).Authenticator(coll.client.authenticator)

if option.Collation != nil {
op.Collation(bsoncore.Document(option.Collation.ToDocument()))
Expand Down Expand Up @@ -1257,7 +1260,7 @@ func (coll *Collection) find(
ClusterClock(coll.client.clock).Database(coll.db.name).Collection(coll.name).
Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).ServerAPI(coll.client.serverAPI).
Timeout(coll.client.timeout).MaxTime(fo.MaxTime).Logger(coll.client.logger).
OmitCSOTMaxTimeMS(omitCSOTMaxTimeMS)
OmitCSOTMaxTimeMS(omitCSOTMaxTimeMS).Authenticator(coll.client.authenticator)

cursorOpts := coll.client.createBaseCursorOptions()

Expand Down Expand Up @@ -1521,7 +1524,7 @@ func (coll *Collection) FindOneAndDelete(ctx context.Context, filter interface{}
}
fod := options.MergeFindOneAndDeleteOptions(opts...)
op := operation.NewFindAndModify(f).Remove(true).ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).
MaxTime(fod.MaxTime)
MaxTime(fod.MaxTime).Authenticator(coll.client.authenticator)
if fod.Collation != nil {
op = op.Collation(bsoncore.Document(fod.Collation.ToDocument()))
}
Expand Down Expand Up @@ -1601,7 +1604,8 @@ func (coll *Collection) FindOneAndReplace(ctx context.Context, filter interface{

fo := options.MergeFindOneAndReplaceOptions(opts...)
op := operation.NewFindAndModify(f).Update(bsoncore.Value{Type: bsontype.EmbeddedDocument, Data: r}).
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).MaxTime(fo.MaxTime)
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).MaxTime(fo.MaxTime).Authenticator(coll.client.authenticator)

if fo.BypassDocumentValidation != nil && *fo.BypassDocumentValidation {
op = op.BypassDocumentValidation(*fo.BypassDocumentValidation)
}
Expand Down Expand Up @@ -1688,7 +1692,7 @@ func (coll *Collection) FindOneAndUpdate(ctx context.Context, filter interface{}

fo := options.MergeFindOneAndUpdateOptions(opts...)
op := operation.NewFindAndModify(f).ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).
MaxTime(fo.MaxTime)
MaxTime(fo.MaxTime).Authenticator(coll.client.authenticator)

u, err := marshalUpdateValue(update, coll.bsonOpts, coll.registry, true)
if err != nil {
Expand Down Expand Up @@ -1894,7 +1898,8 @@ func (coll *Collection) drop(ctx context.Context) error {
ServerSelector(selector).ClusterClock(coll.client.clock).
Database(coll.db.name).Collection(coll.name).
Deployment(coll.client.deployment).Crypt(coll.client.cryptFLE).
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout)
ServerAPI(coll.client.serverAPI).Timeout(coll.client.timeout).
Authenticator(coll.client.authenticator)
err = op.Execute(ctx)

// ignore namespace not found errors
Expand Down
11 changes: 6 additions & 5 deletions mongo/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (db *Database) processRunCommand(ctx context.Context, cmd interface{},
ServerSelector(readSelect).ClusterClock(db.client.clock).
Database(db.name).Deployment(db.client.deployment).
Crypt(db.client.cryptFLE).ReadPreference(ro.ReadPreference).ServerAPI(db.client.serverAPI).
Timeout(db.client.timeout).Logger(db.client.logger), sess, nil
Timeout(db.client.timeout).Logger(db.client.logger).Authenticator(db.client.authenticator), sess, nil
}

// RunCommand executes the given command against the database.
Expand Down Expand Up @@ -308,7 +308,7 @@ func (db *Database) Drop(ctx context.Context) error {
Session(sess).WriteConcern(wc).CommandMonitor(db.client.monitor).
ServerSelector(selector).ClusterClock(db.client.clock).
Database(db.name).Deployment(db.client.deployment).Crypt(db.client.cryptFLE).
ServerAPI(db.client.serverAPI)
ServerAPI(db.client.serverAPI).Authenticator(db.client.authenticator)

err = op.Execute(ctx)

Expand Down Expand Up @@ -402,7 +402,7 @@ func (db *Database) ListCollections(ctx context.Context, filter interface{}, opt
Session(sess).ReadPreference(db.readPreference).CommandMonitor(db.client.monitor).
ServerSelector(selector).ClusterClock(db.client.clock).
Database(db.name).Deployment(db.client.deployment).Crypt(db.client.cryptFLE).
ServerAPI(db.client.serverAPI).Timeout(db.client.timeout)
ServerAPI(db.client.serverAPI).Timeout(db.client.timeout).Authenticator(db.client.authenticator)

cursorOpts := db.client.createBaseCursorOptions()

Expand Down Expand Up @@ -679,7 +679,7 @@ func (db *Database) createCollection(ctx context.Context, name string, opts ...*

func (db *Database) createCollectionOperation(name string, opts ...*options.CreateCollectionOptions) (*operation.Create, error) {
cco := options.MergeCreateCollectionOptions(opts...)
op := operation.NewCreate(name).ServerAPI(db.client.serverAPI)
op := operation.NewCreate(name).ServerAPI(db.client.serverAPI).Authenticator(db.client.authenticator)

if cco.Capped != nil {
op.Capped(*cco.Capped)
Expand Down Expand Up @@ -805,7 +805,8 @@ func (db *Database) CreateView(ctx context.Context, viewName, viewOn string, pip
op := operation.NewCreate(viewName).
ViewOn(viewOn).
Pipeline(pipelineArray).
ServerAPI(db.client.serverAPI)
ServerAPI(db.client.serverAPI).
Authenticator(db.client.authenticator)
cvo := options.MergeCreateViewOptions(opts...)
if cvo.Collation != nil {
op.Collation(bsoncore.Document(cvo.Collation.ToDocument()))
Expand Down
7 changes: 4 additions & 3 deletions mongo/index_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (iv IndexView) List(ctx context.Context, opts ...*options.ListIndexesOption
ServerSelector(selector).ClusterClock(iv.coll.client.clock).
Database(iv.coll.db.name).Collection(iv.coll.name).
Deployment(iv.coll.client.deployment).ServerAPI(iv.coll.client.serverAPI).
Timeout(iv.coll.client.timeout)
Timeout(iv.coll.client.timeout).Authenticator(iv.coll.client.authenticator)

cursorOpts := iv.coll.client.createBaseCursorOptions()

Expand Down Expand Up @@ -262,7 +262,7 @@ func (iv IndexView) CreateMany(ctx context.Context, models []IndexModel, opts ..
Session(sess).WriteConcern(wc).ClusterClock(iv.coll.client.clock).
Database(iv.coll.db.name).Collection(iv.coll.name).CommandMonitor(iv.coll.client.monitor).
Deployment(iv.coll.client.deployment).ServerSelector(selector).ServerAPI(iv.coll.client.serverAPI).
Timeout(iv.coll.client.timeout).MaxTime(option.MaxTime)
Timeout(iv.coll.client.timeout).MaxTime(option.MaxTime).Authenticator(iv.coll.client.authenticator)
if option.CommitQuorum != nil {
commitQuorum, err := marshalValue(option.CommitQuorum, iv.coll.bsonOpts, iv.coll.registry)
if err != nil {
Expand Down Expand Up @@ -402,7 +402,8 @@ func (iv IndexView) drop(ctx context.Context, name string, opts ...*options.Drop
ServerSelector(selector).ClusterClock(iv.coll.client.clock).
Database(iv.coll.db.name).Collection(iv.coll.name).
Deployment(iv.coll.client.deployment).ServerAPI(iv.coll.client.serverAPI).
Timeout(iv.coll.client.timeout).MaxTime(dio.MaxTime)
Timeout(iv.coll.client.timeout).MaxTime(dio.MaxTime).
Authenticator(iv.coll.client.authenticator)

err = op.Execute(ctx)
if err != nil {
Expand Down
Loading
Loading