diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-27 03:19:42 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-27 03:19:42 +0000 |
commit | c3b35c2100dba30c517116bc9a5a4e4149c3a8e5 (patch) | |
tree | ff42c902c4ee9afd7864a2bda8e5e815a876bc76 /net/http/http_auth_handler.h | |
parent | e5be6612288df667ca6ae4a86060bc883a498eea (diff) | |
download | chromium_src-c3b35c2100dba30c517116bc9a5a4e4149c3a8e5.zip chromium_src-c3b35c2100dba30c517116bc9a5a4e4149c3a8e5.tar.gz chromium_src-c3b35c2100dba30c517116bc9a5a4e4149c3a8e5.tar.bz2 |
Initial stab at http authentication (basic + digest) in new http stack.
General design:
- class HttpAuth -- utility class for http-auth logic.
- class HttpAuth::ChallengeTokenizer -- parsing of www-Authenticate headers.
- class HttpAuthHandler -- base class for authentication schemes (inspired by nsIHttpAuthenticator)
- class HttpAuthHandlerBasic : HttpAuthHandler -- logic for basic auth.
- class HttpAuthHandlerDigest : HttpAuthHandler -- logic for digest auth.
- The auth integration in HttpNetworkTransaction mimics that of HttpTransactionWinHttp:
+ HttpNetworkTransaction::ApplyAuth() -- set the authorization headers.
+ HttpNetworkTransaction::PopulateAuthChallenge() -- process the challenges.
BUG=2346
Review URL: http://codereview.chromium.org/4063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2658 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_auth_handler.h')
-rw-r--r-- | net/http/http_auth_handler.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/net/http/http_auth_handler.h b/net/http/http_auth_handler.h new file mode 100644 index 0000000..0608f7b --- /dev/null +++ b/net/http/http_auth_handler.h @@ -0,0 +1,77 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_HTTP_HTTP_AUTH_HANDLER_H_ +#define NET_HTTP_HTTP_AUTH_HANDLER_H_ + +#include <string> + +#include "net/http/http_auth.h" + +namespace net { + +class HttpRequestInfo; +class ProxyInfo; + +// HttpAuthHandler is the interface for the authentication schemes +// (basic, digest, ...) +// The registry mapping auth-schemes to implementations is hardcoded in +// HttpAuth::CreateAuthHandler(). +class HttpAuthHandler { + public: + // Initialize the handler by parsing a challenge string. + bool InitFromChallenge(std::string::const_iterator begin, + std::string::const_iterator end, + HttpAuth::Target target); + + // Lowercase name of the auth scheme + virtual std::string scheme() const { + return scheme_; + } + + // The realm value that was parsed during Init(). + std::string realm() const { + return realm_; + } + + // Numeric rank based on the challenge's security level. Higher + // numbers are better. Used by HttpAuth::ChooseBestChallenge(). + int score() const { + return score_; + } + + HttpAuth::Target target() const { + return target_; + } + + // Generate the Authorization header value. + virtual std::string GenerateCredentials(const std::wstring& username, + const std::wstring& password, + const HttpRequestInfo* request, + const ProxyInfo* proxy) = 0; + + protected: + // Initialize the handler by parsing a challenge string. + // Implementations are expcted to initialize the following members: + // score_, realm_, scheme_ + virtual bool Init(std::string::const_iterator challenge_begin, + std::string::const_iterator challenge_end) = 0; + + // The lowercase auth-scheme {"basic", "digest", "ntlm", ...} + const char* scheme_; + + // The realm. + std::string realm_; + + // The score for this challenge. Higher numbers are better. + int score_; + + // Whether this authentication request is for a proxy server, or an + // origin server. + HttpAuth::Target target_; +}; + +} // namespace net + +#endif // NET_HTTP_HTTP_AUTH_HANDLER_H_ |