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

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

Issue 138753005: Add gnubby authentication to remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change authorization socket flag name Created 6 years, 10 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 #include "remoting/host/client_session.h" 5 #include "remoting/host/client_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "remoting/base/capabilities.h" 10 #include "remoting/base/capabilities.h"
(...skipping 27 matching lines...) Expand all
38 EventHandler* event_handler, 38 EventHandler* event_handler,
39 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, 39 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
40 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 40 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
41 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, 41 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
42 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, 42 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
45 scoped_ptr<protocol::ConnectionToClient> connection, 45 scoped_ptr<protocol::ConnectionToClient> connection,
46 DesktopEnvironmentFactory* desktop_environment_factory, 46 DesktopEnvironmentFactory* desktop_environment_factory,
47 const base::TimeDelta& max_duration, 47 const base::TimeDelta& max_duration,
48 scoped_refptr<protocol::PairingRegistry> pairing_registry) 48 scoped_refptr<protocol::PairingRegistry> pairing_registry,
49 bool enable_gnubby_auth)
49 : event_handler_(event_handler), 50 : event_handler_(event_handler),
50 connection_(connection.Pass()), 51 connection_(connection.Pass()),
51 client_jid_(connection_->session()->jid()), 52 client_jid_(connection_->session()->jid()),
52 control_factory_(this), 53 control_factory_(this),
53 desktop_environment_factory_(desktop_environment_factory), 54 desktop_environment_factory_(desktop_environment_factory),
54 input_tracker_(&host_input_filter_), 55 input_tracker_(&host_input_filter_),
55 remote_input_filter_(&input_tracker_), 56 remote_input_filter_(&input_tracker_),
56 mouse_clamping_filter_(&remote_input_filter_), 57 mouse_clamping_filter_(&remote_input_filter_),
57 disable_input_filter_(mouse_clamping_filter_.input_filter()), 58 disable_input_filter_(mouse_clamping_filter_.input_filter()),
58 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), 59 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
59 auth_input_filter_(&disable_input_filter_), 60 auth_input_filter_(&disable_input_filter_),
60 auth_clipboard_filter_(&disable_clipboard_filter_), 61 auth_clipboard_filter_(&disable_clipboard_filter_),
61 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), 62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
62 max_duration_(max_duration), 63 max_duration_(max_duration),
63 audio_task_runner_(audio_task_runner), 64 audio_task_runner_(audio_task_runner),
64 input_task_runner_(input_task_runner), 65 input_task_runner_(input_task_runner),
65 video_capture_task_runner_(video_capture_task_runner), 66 video_capture_task_runner_(video_capture_task_runner),
66 video_encode_task_runner_(video_encode_task_runner), 67 video_encode_task_runner_(video_encode_task_runner),
67 network_task_runner_(network_task_runner), 68 network_task_runner_(network_task_runner),
68 ui_task_runner_(ui_task_runner), 69 ui_task_runner_(ui_task_runner),
69 pairing_registry_(pairing_registry) { 70 pairing_registry_(pairing_registry),
71 enable_gnubby_auth_(enable_gnubby_auth) {
70 connection_->SetEventHandler(this); 72 connection_->SetEventHandler(this);
71 73
72 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be 74 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be
73 // set before channels are connected. Make it possible to set stubs 75 // set before channels are connected. Make it possible to set stubs
74 // later and set them only when connection is authenticated. 76 // later and set them only when connection is authenticated.
75 connection_->set_clipboard_stub(&auth_clipboard_filter_); 77 connection_->set_clipboard_stub(&auth_clipboard_filter_);
76 connection_->set_host_stub(this); 78 connection_->set_host_stub(this);
77 connection_->set_input_stub(&auth_input_filter_); 79 connection_->set_input_stub(&auth_input_filter_);
78 80
79 // |auth_*_filter_|'s states reflect whether the session is authenticated. 81 // |auth_*_filter_|'s states reflect whether the session is authenticated.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void ClientSession::DeliverClientMessage( 192 void ClientSession::DeliverClientMessage(
191 const protocol::ExtensionMessage& message) { 193 const protocol::ExtensionMessage& message) {
192 if (message.has_type()) { 194 if (message.has_type()) {
193 if (message.type() == "test-echo") { 195 if (message.type() == "test-echo") {
194 protocol::ExtensionMessage reply; 196 protocol::ExtensionMessage reply;
195 reply.set_type("test-echo-reply"); 197 reply.set_type("test-echo-reply");
196 if (message.has_data()) 198 if (message.has_data())
197 reply.set_data(message.data().substr(0, 16)); 199 reply.set_data(message.data().substr(0, 16));
198 connection_->client_stub()->DeliverHostMessage(reply); 200 connection_->client_stub()->DeliverHostMessage(reply);
199 return; 201 return;
202 } else if (message.type() == "gnubby-auth") {
203 if (gnubby_auth_handler_) {
204 gnubby_auth_handler_->DeliverClientMessage(message.data());
205 } else {
206 HOST_LOG << "gnubby auth is not enabled";
207 }
208 return;
200 } 209 }
201 } 210 }
202 // No messages are currently supported.
203 HOST_LOG << "Unexpected message received: " 211 HOST_LOG << "Unexpected message received: "
204 << message.type() << ": " << message.data(); 212 << message.type() << ": " << message.data();
205 } 213 }
206 214
207 void ClientSession::OnConnectionAuthenticated( 215 void ClientSession::OnConnectionAuthenticated(
208 protocol::ConnectionToClient* connection) { 216 protocol::ConnectionToClient* connection) {
209 DCHECK(CalledOnValidThread()); 217 DCHECK(CalledOnValidThread());
210 DCHECK_EQ(connection_.get(), connection); 218 DCHECK_EQ(connection_.get(), connection);
211 DCHECK(!audio_scheduler_.get()); 219 DCHECK(!audio_scheduler_.get());
212 DCHECK(!desktop_environment_); 220 DCHECK(!desktop_environment_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (connection_->session()->config().is_audio_enabled()) { 289 if (connection_->session()->config().is_audio_enabled()) {
282 scoped_ptr<AudioEncoder> audio_encoder = 290 scoped_ptr<AudioEncoder> audio_encoder =
283 CreateAudioEncoder(connection_->session()->config()); 291 CreateAudioEncoder(connection_->session()->config());
284 audio_scheduler_ = new AudioScheduler( 292 audio_scheduler_ = new AudioScheduler(
285 audio_task_runner_, 293 audio_task_runner_,
286 network_task_runner_, 294 network_task_runner_,
287 desktop_environment_->CreateAudioCapturer(), 295 desktop_environment_->CreateAudioCapturer(),
288 audio_encoder.Pass(), 296 audio_encoder.Pass(),
289 connection_->audio_stub()); 297 connection_->audio_stub());
290 } 298 }
299
300 if (enable_gnubby_auth_) {
301 // Create a GnubbyAuthHandler to proxy gnubbyd messages.
302 gnubby_auth_handler_.reset(
303 new GnubbyAuthHandler(connection_->client_stub()));
304 }
291 } 305 }
292 306
293 void ClientSession::OnConnectionChannelsConnected( 307 void ClientSession::OnConnectionChannelsConnected(
294 protocol::ConnectionToClient* connection) { 308 protocol::ConnectionToClient* connection) {
295 DCHECK(CalledOnValidThread()); 309 DCHECK(CalledOnValidThread());
296 DCHECK_EQ(connection_.get(), connection); 310 DCHECK_EQ(connection_.get(), connection);
297 311
298 // Negotiate capabilities with the client. 312 // Negotiate capabilities with the client.
299 if (connection_->session()->config().SupportsCapabilities()) { 313 if (connection_->session()->config().SupportsCapabilities()) {
300 VLOG(1) << "Host capabilities: " << host_capabilities_; 314 VLOG(1) << "Host capabilities: " << host_capabilities_;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void ClientSession::SetDisableInputs(bool disable_inputs) { 419 void ClientSession::SetDisableInputs(bool disable_inputs) {
406 DCHECK(CalledOnValidThread()); 420 DCHECK(CalledOnValidThread());
407 421
408 if (disable_inputs) 422 if (disable_inputs)
409 input_tracker_.ReleaseAll(); 423 input_tracker_.ReleaseAll();
410 424
411 disable_input_filter_.set_enabled(!disable_inputs); 425 disable_input_filter_.set_enabled(!disable_inputs);
412 disable_clipboard_filter_.set_enabled(!disable_inputs); 426 disable_clipboard_filter_.set_enabled(!disable_inputs);
413 } 427 }
414 428
429 void ClientSession::SetGnubbyAuthHandlerForTesting(
430 GnubbyAuthHandler* gnubby_auth_handler) {
431 gnubby_auth_handler_.reset(gnubby_auth_handler);
432 }
433
415 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { 434 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() {
416 DCHECK(CalledOnValidThread()); 435 DCHECK(CalledOnValidThread());
417 436
418 return scoped_ptr<protocol::ClipboardStub>( 437 return scoped_ptr<protocol::ClipboardStub>(
419 new protocol::ClipboardThreadProxy( 438 new protocol::ClipboardThreadProxy(
420 client_clipboard_factory_.GetWeakPtr(), 439 client_clipboard_factory_.GetWeakPtr(),
421 base::MessageLoopProxy::current())); 440 base::MessageLoopProxy::current()));
422 } 441 }
423 442
424 // TODO(sergeyu): Move this to SessionManager? 443 // TODO(sergeyu): Move this to SessionManager?
(...skipping 19 matching lines...) Expand all
444 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); 463 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim());
445 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { 464 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
446 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); 465 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus());
447 } 466 }
448 467
449 NOTREACHED(); 468 NOTREACHED();
450 return scoped_ptr<AudioEncoder>(); 469 return scoped_ptr<AudioEncoder>();
451 } 470 }
452 471
453 } // namespace remoting 472 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698