diff options
Diffstat (limited to 'src/mongo/client/authenticate.h')
-rw-r--r-- | src/mongo/client/authenticate.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mongo/client/authenticate.h b/src/mongo/client/authenticate.h index 7a5a40f6075..65c649c49c2 100644 --- a/src/mongo/client/authenticate.h +++ b/src/mongo/client/authenticate.h @@ -43,16 +43,28 @@ class BSONObj; namespace auth { -using RunCommandResultHandler = stdx::function<void(StatusWith<executor::RemoteCommandResponse>)>; +using AuthResponse = StatusWith<executor::RemoteCommandResponse>; +using AuthCompletionHandler = stdx::function<void(AuthResponse)>; +using RunCommandResultHandler = AuthCompletionHandler; using RunCommandHook = stdx::function<void(executor::RemoteCommandRequest, RunCommandResultHandler)>; /** + * Names for supported authentication mechanisms. + */ + +extern const char* const kMechanismMongoCR; +extern const char* const kMechanismMongoX509; +extern const char* const kMechanismSaslPlain; +extern const char* const kMechanismGSSAPI; +extern const char* const kMechanismScramSha1; + +/** * Authenticate a user. * * Pass the default hostname for this client in through "hostname." If SSL is enabled and * there is a stored client subject name, pass that through the "clientSubjectName" parameter. - * Otherwise, "clientSubjectName" will be ignored, pass in any string. + * Otherwise, "clientSubjectName" will be silently ignored, pass in any string. * * The "params" BSONObj should be initialized with some of the fields below. Which fields * are required depends on the mechanism, which is mandatory. @@ -71,6 +83,10 @@ using RunCommandHook = * Other fields in "params" are silently ignored. A "params" object can be constructed * using the buildAuthParams() method. * + * If a "handler" is provided, this call will execute asynchronously and "handler" will be + * invoked when authentication has completed. If no handler is provided, authenticateClient + * will run synchronously. + * * Returns normally on success, and throws on error. Throws a DBException with getCode() == * ErrorCodes::AuthenticationFailed if authentication is rejected. All other exceptions are * tantamount to authentication failure, but may also indicate more serious problems. @@ -78,7 +94,8 @@ using RunCommandHook = void authenticateClient(const BSONObj& params, StringData hostname, StringData clientSubjectName, - RunCommandHook runCommand); + RunCommandHook runCommand, + AuthCompletionHandler handler = AuthCompletionHandler()); /** * Build a BSONObject representing parameters to be passed to authenticateClient(). Takes |