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

Side by Side Diff: chromeos/login/auth/user_context.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_LOGIN_AUTH_USER_CONTEXT_H_ 5 #ifndef CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ 6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chromeos/chromeos_export.h" 10 #include "chromeos/chromeos_export.h"
11 #include "chromeos/login/auth/key.h" 11 #include "chromeos/login/auth/key.h"
12 #include "components/user_manager/user_id.h"
12 #include "components/user_manager/user_type.h" 13 #include "components/user_manager/user_type.h"
13 14
14 namespace chromeos { 15 namespace chromeos {
15 16
16 // Information that is passed around while authentication is in progress. The 17 // Information that is passed around while authentication is in progress. The
17 // credentials may consist of a |user_id_|, |key_| pair or a GAIA |auth_code_|. 18 // credentials may consist of a |user_id_|, |key_| pair or a GAIA |auth_code_|.
18 // The |user_id_hash_| is used to locate the user's home directory 19 // The |user_id_hash_| is used to locate the user's home directory
19 // mount point for the user. It is set when the mount has been completed. 20 // mount point for the user. It is set when the mount has been completed.
20 class CHROMEOS_EXPORT UserContext { 21 class CHROMEOS_EXPORT UserContext {
21 public: 22 public:
22 // The authentication flow used during sign-in. 23 // The authentication flow used during sign-in.
23 enum AuthFlow { 24 enum AuthFlow {
24 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. 25 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP.
25 AUTH_FLOW_GAIA_WITHOUT_SAML, 26 AUTH_FLOW_GAIA_WITHOUT_SAML,
26 // Online authentication against GAIA. GAIA redirected to a SAML IdP. 27 // Online authentication against GAIA. GAIA redirected to a SAML IdP.
27 AUTH_FLOW_GAIA_WITH_SAML, 28 AUTH_FLOW_GAIA_WITH_SAML,
28 // Offline authentication against a cached key. 29 // Offline authentication against a cached key.
29 AUTH_FLOW_OFFLINE, 30 AUTH_FLOW_OFFLINE,
30 // Offline authentication using and Easy unlock device (e.g. a phone). 31 // Offline authentication using and Easy unlock device (e.g. a phone).
31 AUTH_FLOW_EASY_UNLOCK, 32 AUTH_FLOW_EASY_UNLOCK,
32 // Easy bootstrap flow. 33 // Easy bootstrap flow.
33 AUTH_FLOW_EASY_BOOTSTRAP 34 AUTH_FLOW_EASY_BOOTSTRAP
34 }; 35 };
35 36
36 UserContext(); 37 UserContext();
37 UserContext(const UserContext& other); 38 UserContext(const UserContext& other);
38 explicit UserContext(const std::string& user_id); 39 explicit UserContext(const user_manager::UserID& user_id);
39 UserContext(user_manager::UserType user_type, const std::string& user_id); 40 UserContext(user_manager::UserType user_type, const user_manager::UserID& user _id);
40 ~UserContext(); 41 ~UserContext();
41 42
42 bool operator==(const UserContext& context) const; 43 bool operator==(const UserContext& context) const;
43 bool operator!=(const UserContext& context) const; 44 bool operator!=(const UserContext& context) const;
44 45
45 const std::string& GetUserID() const; 46 const user_manager::UserID& GetUserID() const;
46 const std::string& GetGaiaID() const;
47 const Key* GetKey() const; 47 const Key* GetKey() const;
48 Key* GetKey(); 48 Key* GetKey();
49 const std::string& GetAuthCode() const; 49 const std::string& GetAuthCode() const;
50 const std::string& GetRefreshToken() const; 50 const std::string& GetRefreshToken() const;
51 const std::string& GetAccessToken() const; 51 const std::string& GetAccessToken() const;
52 const std::string& GetUserIDHash() const; 52 const std::string& GetUserIDHash() const;
53 bool IsUsingOAuth() const; 53 bool IsUsingOAuth() const;
54 AuthFlow GetAuthFlow() const; 54 AuthFlow GetAuthFlow() const;
55 user_manager::UserType GetUserType() const; 55 user_manager::UserType GetUserType() const;
56 const std::string& GetPublicSessionLocale() const; 56 const std::string& GetPublicSessionLocale() const;
57 const std::string& GetPublicSessionInputMethod() const; 57 const std::string& GetPublicSessionInputMethod() const;
58 const std::string& GetDeviceId() const; 58 const std::string& GetDeviceId() const;
59 59
60 bool HasCredentials() const; 60 bool HasCredentials() const;
61 61
62 void SetUserID(const std::string& user_id); 62 void SetUserID(const user_manager::UserID& user_id);
63 void SetGaiaID(const std::string& gaia_id);
64 void SetKey(const Key& key); 63 void SetKey(const Key& key);
65 void SetAuthCode(const std::string& auth_code); 64 void SetAuthCode(const std::string& auth_code);
66 void SetRefreshToken(const std::string& refresh_token); 65 void SetRefreshToken(const std::string& refresh_token);
67 void SetAccessToken(const std::string& access_token); 66 void SetAccessToken(const std::string& access_token);
68 void SetUserIDHash(const std::string& user_id_hash); 67 void SetUserIDHash(const std::string& user_id_hash);
69 void SetIsUsingOAuth(bool is_using_oauth); 68 void SetIsUsingOAuth(bool is_using_oauth);
70 void SetAuthFlow(AuthFlow auth_flow); 69 void SetAuthFlow(AuthFlow auth_flow);
71 void SetUserType(user_manager::UserType user_type); 70 void SetUserType(user_manager::UserType user_type);
72 void SetPublicSessionLocale(const std::string& locale); 71 void SetPublicSessionLocale(const std::string& locale);
73 void SetPublicSessionInputMethod(const std::string& input_method); 72 void SetPublicSessionInputMethod(const std::string& input_method);
74 void SetDeviceId(const std::string& device_id); 73 void SetDeviceId(const std::string& device_id);
75 74
76 void ClearSecrets(); 75 void ClearSecrets();
77 76
78 private: 77 private:
79 std::string user_id_; 78 user_manager::UserID user_id_;
80 std::string gaia_id_;
81 Key key_; 79 Key key_;
82 std::string auth_code_; 80 std::string auth_code_;
83 std::string refresh_token_; 81 std::string refresh_token_;
84 std::string access_token_; // OAuthLogin scoped access token. 82 std::string access_token_; // OAuthLogin scoped access token.
85 std::string user_id_hash_; 83 std::string user_id_hash_;
86 bool is_using_oauth_; 84 bool is_using_oauth_;
87 AuthFlow auth_flow_; 85 AuthFlow auth_flow_;
88 user_manager::UserType user_type_; 86 user_manager::UserType user_type_;
89 std::string public_session_locale_; 87 std::string public_session_locale_;
90 std::string public_session_input_method_; 88 std::string public_session_input_method_;
91 std::string device_id_; 89 std::string device_id_;
92 }; 90 };
93 91
94 } // namespace chromeos 92 } // namespace chromeos
95 93
96 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ 94 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698