1 // Copyright (C) MongoDB, Inc. 2017-present. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 7 package auth 8 9 import ( 10 "context" 11 12 "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 13 ) 14 15 // SpeculativeConversation represents an authentication conversation that can be merged with the initial connection 16 // handshake. 17 // 18 // FirstMessage method returns the first message to be sent to the server. This message will be included in the initial 19 // hello command. 20 // 21 // Finish takes the server response to the initial message and conducts the remainder of the conversation to 22 // authenticate the provided connection. 23 type SpeculativeConversation interface { 24 FirstMessage() (bsoncore.Document, error) 25 Finish(ctx context.Context, cfg *Config, firstResponse bsoncore.Document) error 26 } 27 28 // SpeculativeAuthenticator represents an authenticator that supports speculative authentication. 29 type SpeculativeAuthenticator interface { 30 CreateSpeculativeConversation() (SpeculativeConversation, error) 31 } 32