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

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 12313085: Host-side third party token validation (Closed) Base URL: http://git.chromium.org/chromium/src.git@third_party_auth_protocol
Patch Set: Add missing parameters Created 7 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "crypto/nss_util.h" 27 #include "crypto/nss_util.h"
28 #include "ipc/ipc_channel.h" 28 #include "ipc/ipc_channel.h"
29 #include "ipc/ipc_channel_proxy.h" 29 #include "ipc/ipc_channel_proxy.h"
30 #include "ipc/ipc_listener.h" 30 #include "ipc/ipc_listener.h"
31 #include "net/base/network_change_notifier.h" 31 #include "net/base/network_change_notifier.h"
32 #include "net/socket/ssl_server_socket.h" 32 #include "net/socket/ssl_server_socket.h"
33 #include "net/url_request/url_fetcher.h" 33 #include "net/url_request/url_fetcher.h"
34 #include "remoting/base/auto_thread_task_runner.h" 34 #include "remoting/base/auto_thread_task_runner.h"
35 #include "remoting/base/breakpad.h" 35 #include "remoting/base/breakpad.h"
36 #include "remoting/base/constants.h" 36 #include "remoting/base/constants.h"
37 #include "remoting/base/rsa_key_pair.h"
37 #include "remoting/host/branding.h" 38 #include "remoting/host/branding.h"
38 #include "remoting/host/chromoting_host.h" 39 #include "remoting/host/chromoting_host.h"
39 #include "remoting/host/chromoting_host_context.h" 40 #include "remoting/host/chromoting_host_context.h"
40 #include "remoting/host/chromoting_messages.h" 41 #include "remoting/host/chromoting_messages.h"
41 #include "remoting/host/config_file_watcher.h" 42 #include "remoting/host/config_file_watcher.h"
42 #include "remoting/host/curtain_mode.h" 43 #include "remoting/host/curtain_mode.h"
43 #include "remoting/host/curtaining_host_observer.h" 44 #include "remoting/host/curtaining_host_observer.h"
44 #include "remoting/host/desktop_environment.h" 45 #include "remoting/host/desktop_environment.h"
45 #include "remoting/host/desktop_session_connector.h" 46 #include "remoting/host/desktop_session_connector.h"
46 #include "remoting/host/dns_blackhole_checker.h" 47 #include "remoting/host/dns_blackhole_checker.h"
(...skipping 10 matching lines...) Expand all
57 #include "remoting/host/json_host_config.h" 58 #include "remoting/host/json_host_config.h"
58 #include "remoting/host/log_to_server.h" 59 #include "remoting/host/log_to_server.h"
59 #include "remoting/host/logging.h" 60 #include "remoting/host/logging.h"
60 #include "remoting/host/me2me_desktop_environment.h" 61 #include "remoting/host/me2me_desktop_environment.h"
61 #include "remoting/host/network_settings.h" 62 #include "remoting/host/network_settings.h"
62 #include "remoting/host/policy_hack/policy_watcher.h" 63 #include "remoting/host/policy_hack/policy_watcher.h"
63 #include "remoting/host/service_urls.h" 64 #include "remoting/host/service_urls.h"
64 #include "remoting/host/session_manager_factory.h" 65 #include "remoting/host/session_manager_factory.h"
65 #include "remoting/host/signaling_connector.h" 66 #include "remoting/host/signaling_connector.h"
66 #include "remoting/host/ui_strings.h" 67 #include "remoting/host/ui_strings.h"
68 #include "remoting/host/url_fetcher_token_validator_factory.h"
67 #include "remoting/host/usage_stats_consent.h" 69 #include "remoting/host/usage_stats_consent.h"
68 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 70 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
69 #include "remoting/protocol/me2me_host_authenticator_factory.h" 71 #include "remoting/protocol/me2me_host_authenticator_factory.h"
70 72
71 #if defined(OS_POSIX) 73 #if defined(OS_POSIX)
72 #include <pwd.h> 74 #include <pwd.h>
73 #include <signal.h> 75 #include <signal.h>
74 #include "base/file_descriptor_posix.h" 76 #include "base/file_descriptor_posix.h"
75 #include "remoting/host/pam_authorization_factory_posix.h" 77 #include "remoting/host/pam_authorization_factory_posix.h"
76 #include "remoting/host/posix/signal_handler.h" 78 #include "remoting/host/posix/signal_handler.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 229
228 // Applies the host config, returning true if successful. 230 // Applies the host config, returning true if successful.
229 bool ApplyConfig(scoped_ptr<JsonHostConfig> config); 231 bool ApplyConfig(scoped_ptr<JsonHostConfig> config);
230 232
231 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 233 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
232 bool OnHostDomainPolicyUpdate(const std::string& host_domain); 234 bool OnHostDomainPolicyUpdate(const std::string& host_domain);
233 bool OnUsernamePolicyUpdate(bool username_match_required); 235 bool OnUsernamePolicyUpdate(bool username_match_required);
234 bool OnNatPolicyUpdate(bool nat_traversal_enabled); 236 bool OnNatPolicyUpdate(bool nat_traversal_enabled);
235 bool OnCurtainPolicyUpdate(bool curtain_required); 237 bool OnCurtainPolicyUpdate(bool curtain_required);
236 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); 238 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix);
239 bool OnHostTokenUrlPolicyUpdate(const GURL& token_url,
240 const GURL& token_validation_url);
237 241
238 void StartHost(); 242 void StartHost();
239 243
240 void OnAuthFailed(); 244 void OnAuthFailed();
241 245
242 void OnCurtainModeFailed(); 246 void OnCurtainModeFailed();
243 247
244 void OnRemoteSessionSwitchedToConsole(); 248 void OnRemoteSessionSwitchedToConsole();
245 249
246 // Invoked when the user uses the Disconnect windows to terminate 250 // Invoked when the user uses the Disconnect windows to terminate
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 std::string xmpp_login_; 294 std::string xmpp_login_;
291 std::string xmpp_auth_token_; 295 std::string xmpp_auth_token_;
292 std::string xmpp_auth_service_; 296 std::string xmpp_auth_service_;
293 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 297 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
294 bool allow_nat_traversal_; 298 bool allow_nat_traversal_;
295 std::string talkgadget_prefix_; 299 std::string talkgadget_prefix_;
296 300
297 scoped_ptr<CurtainMode> curtain_; 301 scoped_ptr<CurtainMode> curtain_;
298 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; 302 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_;
299 bool curtain_required_; 303 bool curtain_required_;
304 GURL token_url_;
305 GURL token_validation_url_;
306 scoped_ptr<UrlFetcherTokenValidatorFactory> token_validator_factory_;
300 307
301 scoped_ptr<XmppSignalStrategy> signal_strategy_; 308 scoped_ptr<XmppSignalStrategy> signal_strategy_;
302 scoped_ptr<SignalingConnector> signaling_connector_; 309 scoped_ptr<SignalingConnector> signaling_connector_;
303 scoped_ptr<HeartbeatSender> heartbeat_sender_; 310 scoped_ptr<HeartbeatSender> heartbeat_sender_;
304 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; 311 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_;
305 scoped_ptr<LogToServer> log_to_server_; 312 scoped_ptr<LogToServer> log_to_server_;
306 scoped_ptr<HostEventLogger> host_event_logger_; 313 scoped_ptr<HostEventLogger> host_event_logger_;
307 314
308 // Created on the UI thread and used on the network thread. 315 // Created on the UI thread and used on the network thread.
309 scoped_ptr<HostUserInterface> host_user_interface_; 316 scoped_ptr<HostUserInterface> host_user_interface_;
(...skipping 22 matching lines...) Expand all
332 ALLOW_THIS_IN_INITIALIZER_LIST(self_(this)), 339 ALLOW_THIS_IN_INITIALIZER_LIST(self_(this)),
333 exit_code_out_(exit_code_out) { 340 exit_code_out_(exit_code_out) {
334 // Create the platform-specific curtain-mode implementation. 341 // Create the platform-specific curtain-mode implementation.
335 // TODO(wez): Create this on the network thread? 342 // TODO(wez): Create this on the network thread?
336 curtain_ = CurtainMode::Create( 343 curtain_ = CurtainMode::Create(
337 base::Bind(&HostProcess::OnRemoteSessionSwitchedToConsole, 344 base::Bind(&HostProcess::OnRemoteSessionSwitchedToConsole,
338 base::Unretained(this)), 345 base::Unretained(this)),
339 base::Bind(&HostProcess::OnCurtainModeFailed, 346 base::Bind(&HostProcess::OnCurtainModeFailed,
340 base::Unretained(this))); 347 base::Unretained(this)));
341 348
349 // Create the validator factory for third-party token authentication.
350 token_validator_factory_.reset(new UrlFetcherTokenValidatorFactory(
351 context_->url_request_context_getter()));
352
342 StartOnUiThread(); 353 StartOnUiThread();
343 } 354 }
344 355
345 HostProcess::~HostProcess() { 356 HostProcess::~HostProcess() {
346 // Verify that UI components have been torn down. 357 // Verify that UI components have been torn down.
347 DCHECK(!config_watcher_); 358 DCHECK(!config_watcher_);
348 DCHECK(!daemon_channel_); 359 DCHECK(!daemon_channel_);
349 DCHECK(!desktop_environment_factory_); 360 DCHECK(!desktop_environment_factory_);
350 DCHECK(!host_user_interface_); 361 DCHECK(!host_user_interface_);
351 362
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 517
507 std::string local_certificate = key_pair_->GenerateCertificate(); 518 std::string local_certificate = key_pair_->GenerateCertificate();
508 if (local_certificate.empty()) { 519 if (local_certificate.empty()) {
509 LOG(ERROR) << "Failed to generate host certificate."; 520 LOG(ERROR) << "Failed to generate host certificate.";
510 ShutdownHost(kInitializationFailed); 521 ShutdownHost(kInitializationFailed);
511 return; 522 return;
512 } 523 }
513 524
514 scoped_ptr<protocol::AuthenticatorFactory> factory( 525 scoped_ptr<protocol::AuthenticatorFactory> factory(
515 new protocol::Me2MeHostAuthenticatorFactory( 526 new protocol::Me2MeHostAuthenticatorFactory(
516 local_certificate, key_pair_, host_secret_hash_)); 527 local_certificate, key_pair_, host_secret_hash_,
528 token_url_, token_validation_url_, token_validator_factory_.get()));
517 #if defined(OS_POSIX) 529 #if defined(OS_POSIX)
518 // On Linux and Mac, perform a PAM authorization step after authentication. 530 // On Linux and Mac, perform a PAM authorization step after authentication.
519 factory.reset(new PamAuthorizationFactory(factory.Pass())); 531 factory.reset(new PamAuthorizationFactory(factory.Pass()));
520 #endif 532 #endif
521 host_->SetAuthenticatorFactory(factory.Pass()); 533 host_->SetAuthenticatorFactory(factory.Pass());
522 } 534 }
523 535
524 // IPC::Listener implementation. 536 // IPC::Listener implementation.
525 bool HostProcess::OnMessageReceived(const IPC::Message& message) { 537 bool HostProcess::OnMessageReceived(const IPC::Message& message) {
526 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 538 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (policies->GetString( 776 if (policies->GetString(
765 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName, 777 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
766 &string_value)) { 778 &string_value)) {
767 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value); 779 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
768 } 780 }
769 if (policies->GetBoolean( 781 if (policies->GetBoolean(
770 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName, 782 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
771 &bool_value)) { 783 &bool_value)) {
772 restart_required |= OnCurtainPolicyUpdate(bool_value); 784 restart_required |= OnCurtainPolicyUpdate(bool_value);
773 } 785 }
786 std::string token_url_string, token_validation_url_string;
787 if (policies->GetString(
788 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName,
789 &token_url_string) &&
790 policies->GetString(
791 policy_hack::PolicyWatcher::kHostTokenValidationUrlPolicyName,
792 &token_validation_url_string)) {
793 restart_required |= OnHostTokenUrlPolicyUpdate(
794 GURL(token_url_string), GURL(token_validation_url_string));
795 }
774 796
775 if (state_ == HOST_INITIALIZING) { 797 if (state_ == HOST_INITIALIZING) {
776 StartHost(); 798 StartHost();
777 } else if (state_ == HOST_STARTED && restart_required) { 799 } else if (state_ == HOST_STARTED && restart_required) {
778 RestartHost(); 800 RestartHost();
779 } 801 }
780 } 802 }
781 803
782 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { 804 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) {
783 // Returns true if the host has to be restarted after this policy update. 805 // Returns true if the host has to be restarted after this policy update.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 908 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
887 909
888 if (talkgadget_prefix != talkgadget_prefix_) { 910 if (talkgadget_prefix != talkgadget_prefix_) {
889 LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix; 911 LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix;
890 talkgadget_prefix_ = talkgadget_prefix; 912 talkgadget_prefix_ = talkgadget_prefix;
891 return true; 913 return true;
892 } 914 }
893 return false; 915 return false;
894 } 916 }
895 917
918 bool HostProcess::OnHostTokenUrlPolicyUpdate(
919 const GURL& token_url,
920 const GURL& token_validation_url) {
921 // Returns true if the host has to be restarted after this policy update.
922 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
923
924 if (token_url_ != token_url ||
925 token_validation_url_ != token_validation_url) {
926 if (token_url.is_empty() && token_validation_url.is_empty()) {
927 LOG(INFO) << "Policy disables third-party authentication";
928 } else if ((!token_url.is_valid() || !token_validation_url.is_valid())) {
929 LOG(ERROR) << "One of the third-party token URLs is empty or invalid. "
930 << "TokenUrl: " << token_url << ", "
931 << "TokenValidationUrl: " << token_validation_url;
932 } else {
933 LOG(INFO) << "Policy sets third-party token URLs: "
934 << "TokenUrl: " << token_url << ", "
935 << "TokenValidationUrl: " << token_validation_url;
936 }
937
938 token_url_ = token_url;
939 token_validation_url_ = token_validation_url;
940 return true;
941 }
942
943 return false;
944 }
945
896 void HostProcess::StartHost() { 946 void HostProcess::StartHost() {
897 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 947 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
898 DCHECK(!host_); 948 DCHECK(!host_);
899 DCHECK(!signal_strategy_.get()); 949 DCHECK(!signal_strategy_.get());
900 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || 950 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART ||
901 state_ == HOST_STOPPED) << state_; 951 state_ == HOST_STOPPED) << state_;
902 state_ = HOST_STARTED; 952 state_ = HOST_STARTED;
903 953
904 signal_strategy_.reset( 954 signal_strategy_.reset(
905 new XmppSignalStrategy(context_->url_request_context_getter(), 955 new XmppSignalStrategy(context_->url_request_context_getter(),
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 return exit_code; 1195 return exit_code;
1146 } 1196 }
1147 1197
1148 } // namespace remoting 1198 } // namespace remoting
1149 1199
1150 #if !defined(OS_WIN) 1200 #if !defined(OS_WIN)
1151 int main(int argc, char** argv) { 1201 int main(int argc, char** argv) {
1152 return remoting::HostMain(argc, argv); 1202 return remoting::HostMain(argc, argv);
1153 } 1203 }
1154 #endif // !defined(OS_WIN) 1204 #endif // !defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698