| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_auth_handler_negotiate.h" | 5 #include "net/http/http_auth_handler_negotiate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/base/address_family.h" | 8 #include "net/base/address_family.h" |
| 9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool HttpAuthHandlerNegotiate::AllowsDefaultCredentials() { | 104 bool HttpAuthHandlerNegotiate::AllowsDefaultCredentials() { |
| 105 if (target_ == HttpAuth::AUTH_PROXY) | 105 if (target_ == HttpAuth::AUTH_PROXY) |
| 106 return true; | 106 return true; |
| 107 if (!url_security_manager_) | 107 if (!url_security_manager_) |
| 108 return false; | 108 return false; |
| 109 return url_security_manager_->CanUseDefaultCredentials(origin_); | 109 return url_security_manager_->CanUseDefaultCredentials(origin_); |
| 110 } | 110 } |
| 111 | 111 |
| 112 std::wstring HttpAuthHandlerNegotiate::CreateSPN( | 112 std::wstring HttpAuthHandlerNegotiate::CreateSPN( |
| 113 const AddressList& address_list, const GURL& origin) { | 113 const AddressList& address_list, const GURL& origin) { |
| 114 // Kerberos SPNs are in the form HTTP/<host>:<port> | 114 // Kerberos Web Server SPNs are in the form HTTP/<host>:<port> through SSPI, |
| 115 // and in the form HTTP@<host>:<port> through GSSAPI |
| 115 // http://msdn.microsoft.com/en-us/library/ms677601%28VS.85%29.aspx | 116 // http://msdn.microsoft.com/en-us/library/ms677601%28VS.85%29.aspx |
| 116 // | 117 // |
| 117 // However, reality differs from the specification. A good description of | 118 // However, reality differs from the specification. A good description of |
| 118 // the problems can be found here: | 119 // the problems can be found here: |
| 119 // http://blog.michelbarneveld.nl/michel/archive/2009/11/14/the-reason-why-k
b911149-and-kb908209-are-not-the-soluton.aspx | 120 // http://blog.michelbarneveld.nl/michel/archive/2009/11/14/the-reason-why-k
b911149-and-kb908209-are-not-the-soluton.aspx |
| 120 // | 121 // |
| 121 // Typically the <host> portion should be the canonical FQDN for the service. | 122 // Typically the <host> portion should be the canonical FQDN for the service. |
| 122 // If this could not be resolved, the original hostname in the URL will be | 123 // If this could not be resolved, the original hostname in the URL will be |
| 123 // attempted instead. However, some intranets register SPNs using aliases | 124 // attempted instead. However, some intranets register SPNs using aliases |
| 124 // for the same canonical DNS name to allow multiple web services to reside | 125 // for the same canonical DNS name to allow multiple web services to reside |
| (...skipping 11 matching lines...) Expand all Loading... |
| 136 // option to include non-standard ports as of 3.6. | 137 // option to include non-standard ports as of 3.6. |
| 137 // http://support.microsoft.com/kb/908209 | 138 // http://support.microsoft.com/kb/908209 |
| 138 // | 139 // |
| 139 // Without any command-line flags, Chrome matches the behavior of Firefox | 140 // Without any command-line flags, Chrome matches the behavior of Firefox |
| 140 // and IE. Users can override the behavior so aliases are allowed and | 141 // and IE. Users can override the behavior so aliases are allowed and |
| 141 // non-standard ports are included. | 142 // non-standard ports are included. |
| 142 int port = origin.EffectiveIntPort(); | 143 int port = origin.EffectiveIntPort(); |
| 143 std::string server; | 144 std::string server; |
| 144 if (!address_list.GetCanonicalName(&server)) | 145 if (!address_list.GetCanonicalName(&server)) |
| 145 server = origin.host(); | 146 server = origin.host(); |
| 147 #if defined(OS_WIN) |
| 148 static const char kSpnSeparator = '/'; |
| 149 #elif defined(OS_POSIX) |
| 150 static const char kSpnSeparator = '@'; |
| 151 #endif |
| 146 if (port != 80 && port != 443 && use_port_) { | 152 if (port != 80 && port != 443 && use_port_) { |
| 147 return ASCIIToWide(StringPrintf("HTTP/%s:%d", server.c_str(), port)); | 153 return ASCIIToWide(StringPrintf("HTTP%c%s:%d", kSpnSeparator, |
| 154 server.c_str(), port)); |
| 148 } else { | 155 } else { |
| 149 return ASCIIToWide(StringPrintf("HTTP/%s", server.c_str())); | 156 return ASCIIToWide(StringPrintf("HTTP%c%s", kSpnSeparator, server.c_str())); |
| 150 } | 157 } |
| 151 } | 158 } |
| 152 | 159 |
| 153 int HttpAuthHandlerNegotiate::DoLoop(int result) { | 160 int HttpAuthHandlerNegotiate::DoLoop(int result) { |
| 154 DCHECK(next_state_ != STATE_NONE); | 161 DCHECK(next_state_ != STATE_NONE); |
| 155 | 162 |
| 156 int rv = result; | 163 int rv = result; |
| 157 do { | 164 do { |
| 158 State state = next_state_; | 165 State state = next_state_; |
| 159 next_state_ = STATE_NONE; | 166 next_state_ = STATE_NONE; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 resolver_, disable_cname_lookup_, | 307 resolver_, disable_cname_lookup_, |
| 301 use_port_)); | 308 use_port_)); |
| 302 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 309 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
| 303 return ERR_INVALID_RESPONSE; | 310 return ERR_INVALID_RESPONSE; |
| 304 handler->swap(tmp_handler); | 311 handler->swap(tmp_handler); |
| 305 return OK; | 312 return OK; |
| 306 #endif | 313 #endif |
| 307 } | 314 } |
| 308 | 315 |
| 309 } // namespace net | 316 } // namespace net |
| OLD | NEW |