Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ |
| 7 | 7 |
| 8 #include <cstdint> | |
| 8 #include <memory> | 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class FilePath; | 16 class FilePath; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 20 // Class responsible for proxying authentication data between a local gnubbyd | 21 // Class responsible for proxying authentication data between a local gnubbyd |
| 21 // and the client. | 22 // and the client. |
| 22 class GnubbyAuthHandler { | 23 class GnubbyAuthHandler { |
| 23 public: | 24 public: |
| 24 virtual ~GnubbyAuthHandler() {} | 25 virtual ~GnubbyAuthHandler() {} |
| 25 | 26 |
| 26 // Used to send gnubby extension messages to the client. | 27 // Used to send gnubby extension messages to the client. |
| 27 typedef base::Callback<void(int connection_id, const std::string& data)> | 28 typedef base::Callback<void(int connection_id, const std::string& data)> |
| 28 SendMessageCallback; | 29 SendMessageCallback; |
| 29 | 30 |
| 31 // Returns the value of the current session being remoted. Used to ensure | |
| 32 // global resources are only accessed from the remoted user session. | |
| 33 typedef base::Callback<uint32_t()> SessionIdCallback; | |
| 34 | |
| 30 // Creates a platform-specific GnubbyAuthHandler. | 35 // Creates a platform-specific GnubbyAuthHandler. |
| 31 // All invocations of |callback| are guaranteed to occur before the underlying | 36 // All invocations of the callbacks are guaranteed to occur before the |
| 32 // GnubbyAuthHandler object is destroyed. It is not safe to destroy the | 37 // underlying GnubbyAuthHandler object is destroyed. It is not safe to |
| 33 // GnubbyAuthHandler object within the callback. | 38 // destroy the GnubbyAuthHandler object within the callback. |
| 34 static std::unique_ptr<GnubbyAuthHandler> Create( | 39 static std::unique_ptr<GnubbyAuthHandler> Create( |
| 35 const SendMessageCallback& callback); | 40 const SendMessageCallback& send_message_callback, |
| 41 const SessionIdCallback& session_id_callback); | |
|
Sergey Ulanov
2016/06/27 23:51:58
Why does the callback need to be passed to Create(
joedow
2016/06/28 01:27:34
The session ID can change at any time (e.g. when a
Sergey Ulanov
2016/06/28 18:08:03
Even if session ID may change it doesn't mean we n
joedow
2016/06/28 21:36:21
The host definitely knows when the session id is c
| |
| 36 | 42 |
| 37 #if defined(OS_LINUX) | 43 #if defined(OS_LINUX) |
| 38 // Specify the name of the socket to listen to gnubby requests on. | 44 // Specify the name of the socket to listen to gnubby requests on. |
| 39 static void SetGnubbySocketName(const base::FilePath& gnubby_socket_name); | 45 static void SetGnubbySocketName(const base::FilePath& gnubby_socket_name); |
| 40 #endif // defined(OS_LINUX) | 46 #endif // defined(OS_LINUX) |
| 41 | 47 |
| 42 // Sets the callback used to send messages to the client. | 48 // Sets the callback used to send messages to the client. |
| 43 virtual void SetSendMessageCallback(const SendMessageCallback& callback) = 0; | 49 virtual void SetSendMessageCallback(const SendMessageCallback& callback) = 0; |
| 44 | 50 |
| 51 // Sets the callback used to retrieve the current session ID. | |
| 52 virtual void SetSessionIdCallback(const SessionIdCallback& callback) = 0; | |
| 53 | |
| 45 // Creates the platform specific connection to handle gnubby requests. | 54 // Creates the platform specific connection to handle gnubby requests. |
| 46 virtual void CreateGnubbyConnection() = 0; | 55 virtual void CreateGnubbyConnection() = 0; |
| 47 | 56 |
| 48 // Returns true if |gnubby_connection_id| represents a valid connection. | 57 // Returns true if |gnubby_connection_id| represents a valid connection. |
| 49 virtual bool IsValidConnectionId(int gnubby_connection_id) const = 0; | 58 virtual bool IsValidConnectionId(int gnubby_connection_id) const = 0; |
| 50 | 59 |
| 51 // Sends the gnubby response from the client to the local gnubby agent. | 60 // Sends the gnubby response from the client to the local gnubby agent. |
| 52 virtual void SendClientResponse(int gnubby_connection_id, | 61 virtual void SendClientResponse(int gnubby_connection_id, |
| 53 const std::string& response) = 0; | 62 const std::string& response) = 0; |
| 54 | 63 |
| 55 // Closes the gnubby connection represented by |gnubby_connection_id|. | 64 // Closes the gnubby connection represented by |gnubby_connection_id|. |
| 56 virtual void SendErrorAndCloseConnection(int gnubby_connection_id) = 0; | 65 virtual void SendErrorAndCloseConnection(int gnubby_connection_id) = 0; |
| 57 | 66 |
| 58 // Returns the number of active gnubby connections. | 67 // Returns the number of active gnubby connections. |
| 59 virtual size_t GetActiveConnectionCountForTest() const = 0; | 68 virtual size_t GetActiveConnectionCountForTest() const = 0; |
| 60 | 69 |
| 61 // Sets the timeout used when waiting for a gnubby response. | 70 // Sets the timeout used when waiting for a gnubby response. |
| 62 virtual void SetRequestTimeoutForTest(base::TimeDelta timeout) = 0; | 71 virtual void SetRequestTimeoutForTest(base::TimeDelta timeout) = 0; |
| 63 }; | 72 }; |
| 64 | 73 |
| 65 } // namespace remoting | 74 } // namespace remoting |
| 66 | 75 |
| 67 #endif // REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ | 76 #endif // REMOTING_HOST_SECURITY_KEY_GNUBBY_AUTH_HANDLER_H_ |
| OLD | NEW |