diff options
author | samantharitter <samantha.ritter@10gen.com> | 2015-07-29 15:43:51 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2015-08-10 13:30:28 -0400 |
commit | eecbe12db69e2b1a5bf83c8374200331a7ba5225 (patch) | |
tree | c52f4d6ba754050e8df869a6da32bede10f1176c /src/mongo/client/authenticate.h | |
parent | 5e384621d664132346df3044bb5007597faa123c (diff) | |
download | mongo-eecbe12db69e2b1a5bf83c8374200331a7ba5225.tar.gz |
SERVER-19155 Refactor auth methods for asynchronous handlers
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 |