Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: net/http/http_auth_handler_ntlm.h

Issue 159656: Include SSPI support for NTLM authentication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: files moved Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_auth_handler_ntlm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_handler_ntlm.h
===================================================================
--- net/http/http_auth_handler_ntlm.h (revision 22897)
+++ net/http/http_auth_handler_ntlm.h (working copy)
@@ -7,18 +7,50 @@
#include <string>
+#include "build/build_config.h"
+// This contains the portable and the SSPI implementation for NTLM.
+// We use NTLM_PORTABLE for Linux and OSX, for windows NTLM_SSPI is preferred.
+#if defined(OS_WIN)
+#define NTLM_SSPI
+#elif defined(OS_MACOSX) || defined(OS_LINUX)
+#define NTLM_PORTABLE
+#endif
+
+#if defined(NTLM_SSPI)
+#include <windows.h>
+#define SECURITY_WIN32
+#include <security.h>
+#endif
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
#include "net/http/http_auth_handler.h"
+#include "net/base/net_errors.h"
namespace net {
+static inline void ZapBuf(void* buf, size_t buf_len) {
+ memset(buf, 0, buf_len);
+}
+
+// TODO(wtc): Can we implement ZapString as
+// s.replace(0, s.size(), s.size(), '\0)?
+static inline void ZapString(std::string* s) {
+ ZapBuf(&(*s)[0], s->length());
+}
+
+static inline void ZapString(string16* s) {
+ ZapBuf(&(*s)[0], s->length() * 2);
+}
+
class NTLMAuthModule;
// Code for handling HTTP NTLM authentication.
class HttpAuthHandlerNTLM : public HttpAuthHandler {
public:
+
+#if defined(NTLM_PORTABLE)
// A function that generates n random bytes in the output buffer.
typedef void (*GenerateRandomProc)(uint8* output, size_t n);
@@ -45,6 +77,7 @@
GenerateRandomProc old_random_proc_;
HostNameProc old_host_name_proc_;
};
+#endif
HttpAuthHandlerNTLM();
@@ -63,11 +96,16 @@
return ParseChallenge(challenge_begin, challenge_end);
}
+ // This function is implemented in the SSPI layer to get Credentials
+ int InitializeBeforeFirstChallenge();
+
private:
+#if defined(NTLM_PORTABLE)
// For unit tests to override the GenerateRandom and GetHostName functions.
// Returns the old function.
static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc);
static HostNameProc SetHostNameProc(HostNameProc proc);
+#endif
// Parse the challenge, saving the results into this instance.
// Returns true on success.
@@ -81,9 +119,16 @@
void** out_token,
uint32* out_token_len);
+#if defined(NTLM_SSPI)
+ void ResetSecurityContext();
+#endif
+
+#if defined(NTLM_PORTABLE)
static GenerateRandomProc generate_random_proc_;
static HostNameProc get_host_name_proc_;
+#endif
+ protected:
string16 domain_;
string16 username_;
string16 password_;
@@ -91,6 +136,12 @@
// The base64-encoded string following "NTLM" in the "WWW-Authenticate" or
// "Proxy-Authenticate" response header.
std::string auth_data_;
+
+#if defined(NTLM_SSPI)
+ ULONG max_token_len_;
+ CredHandle cred_;
+ CtxtHandle ctxt_;
+#endif
};
} // namespace net
« no previous file with comments | « no previous file | net/http/http_auth_handler_ntlm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698