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

Side by Side Diff: chromeos/dbus/auth_policy_client.h

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Fix profile creation, mojo types + rebase. Created 4 years 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_
6 #define CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ 6 #define CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "chromeos/chromeos_export.h" 11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h" 12 #include "chromeos/dbus/dbus_client.h"
13 13
14 // TODO(rsorokin): Switch to service constants when it's landed. 14 // TODO(rsorokin): Switch to service constants when it's landed.
15 // (see crbug.com/659732) 15 // (see crbug.com/659732)
16 namespace authpolicy { 16 namespace authpolicy {
17 namespace types { 17 namespace types {
18
18 enum ADJoinErrorType { 19 enum ADJoinErrorType {
19 AD_JOIN_ERROR_NONE = 0, 20 AD_JOIN_ERROR_NONE = 0,
20 AD_JOIN_ERROR_UNKNOWN = 1, 21 AD_JOIN_ERROR_UNKNOWN = 1,
21 AD_JOIN_ERROR_DBUS_FAIL = 2, 22 AD_JOIN_ERROR_DBUS_FAIL = 2,
22 }; 23 };
24
25 enum AuthUserErrorType {
26 AUTH_USER_ERROR_NONE = 0,
27 AUTH_USER_ERROR_UNKNOWN = 1,
28 AUTH_USER_ERROR_DBUS_FAILURE = 2,
29 };
30
23 } // namespace types 31 } // namespace types
24 } // namespace authpolicy 32 } // namespace authpolicy
25 33
26 namespace chromeos { 34 namespace chromeos {
27 35
28 // AuthPolicyClient is used to communicate with the org.chromium.AuthPolicy 36 // AuthPolicyClient is used to communicate with the org.chromium.AuthPolicy
29 // sevice. All method should be called from the origin thread (UI thread) which 37 // sevice. All method should be called from the origin thread (UI thread) which
30 // initializes the DBusThreadManager instance. 38 // initializes the DBusThreadManager instance.
31 class CHROMEOS_EXPORT AuthPolicyClient : public DBusClient { 39 class CHROMEOS_EXPORT AuthPolicyClient : public DBusClient {
32 public: 40 public:
41 // |user_id| is a unique id for the users. Using objectGUID from Active
42 // Directory server.
43 using AuthCallback =
44 base::Callback<void(int error_code, const std::string& user_id)>;
33 using JoinCallback = base::Callback<void(int error_code)>; 45 using JoinCallback = base::Callback<void(int error_code)>;
34 using RefreshPolicyCallback = base::Callback<void(bool success)>; 46 using RefreshPolicyCallback = base::Callback<void(bool success)>;
35 47
36 ~AuthPolicyClient() override; 48 ~AuthPolicyClient() override;
37 49
38 // Factory function, creates a new instance and returns ownership. 50 // Factory function, creates a new instance and returns ownership.
39 // For normal usage, access the singleton via DBusThreadManager::Get(). 51 // For normal usage, access the singleton via DBusThreadManager::Get().
40 static AuthPolicyClient* Create(); 52 static AuthPolicyClient* Create();
41 53
42 // Calls JoinADDomain. It runs "net ads join ..." which joins machine to 54 // Calls JoinADDomain. It runs "net ads join ..." which joins machine to
43 // Active directory domain. 55 // Active directory domain.
44 // |machine_name| is a name for a local machine. |user|, 56 // |machine_name| is a name for a local machine. |user_principal_name|,
45 // |password_fd| are credentials of the Active directory account which has 57 // |password_fd| are credentials of the Active directory account which has
46 // right to join the machine to the domain. |password_fd| is a file descriptor 58 // right to join the machine to the domain. |password_fd| is a file descriptor
47 // password is read from. The caller should close it after the call. 59 // password is read from. The caller should close it after the call.
48 // |callback| is called after the method call succeeds. 60 // |callback| is called after getting (or failing to get) D-BUS response.
49 virtual void JoinAdDomain(const std::string& machine_name, 61 virtual void JoinAdDomain(const std::string& machine_name,
50 const std::string& user, 62 const std::string& user_principal_name,
51 int password_fd, 63 int password_fd,
52 const JoinCallback& callback) = 0; 64 const JoinCallback& callback) = 0;
53 65
66 // Calls AuthenticateUser. It runs "kinit <user_principal_name> .. " which
67 // does kerberos authentication against Active Directory server.
68 // |password_fd| is similar to the one in the JoinAdDomain.
69 // |callback| is called after getting (or failing to get) D-BUS response.
70 virtual void AuthenticateUser(const std::string& user_principal_name,
71 int password_fd,
72 const AuthCallback& callback) = 0;
73
54 // Calls RefreshDevicePolicy - handle policy for the device. 74 // Calls RefreshDevicePolicy - handle policy for the device.
55 // Fetch GPO files from Active directory server, parse it, encode it into 75 // Fetch GPO files from Active directory server, parse it, encode it into
56 // protobuf and send to SessionManager. Callback is called after that. 76 // protobuf and send to SessionManager. Callback is called after that.
57 virtual void RefreshDevicePolicy(const RefreshPolicyCallback& callback) = 0; 77 virtual void RefreshDevicePolicy(const RefreshPolicyCallback& callback) = 0;
58 78
59 // Calls RefreshUserPolicy - handle policy for the user specified by 79 // Calls RefreshUserPolicy - handle policy for the user specified by
60 // |account_id|. Similar to RefreshDevicePolicy. 80 // |account_id|. Similar to RefreshDevicePolicy.
61 virtual void RefreshUserPolicy(const std::string& account_id, 81 virtual void RefreshUserPolicy(const std::string& account_id,
62 const RefreshPolicyCallback& callback) = 0; 82 const RefreshPolicyCallback& callback) = 0;
63 83
64 protected: 84 protected:
65 // Create() should be used instead. 85 // Create() should be used instead.
66 AuthPolicyClient(); 86 AuthPolicyClient();
67 87
68 private: 88 private:
69 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClient); 89 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClient);
70 }; 90 };
71 91
72 } // namespace chromeos 92 } // namespace chromeos
73 93
74 #endif // CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ 94 #endif // CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698