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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
10 #include "chromeos/chromeos_export.h"
11 #include "chromeos/login/auth/key.h"
12 #include "components/user_manager/user_type.h"
16 // 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 // 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 class CHROMEOS_EXPORT UserContext
{
22 // The authentication flow used during sign-in.
24 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP.
25 AUTH_FLOW_GAIA_WITHOUT_SAML
,
26 // Online authentication against GAIA. GAIA redirected to a SAML IdP.
27 AUTH_FLOW_GAIA_WITH_SAML
,
28 // Offline authentication against a cached key.
30 // Offline authentication using and Easy unlock device (e.g. a phone).
35 UserContext(const UserContext
& other
);
36 explicit UserContext(const std::string
& user_id
);
37 UserContext(user_manager::UserType user_type
, const std::string
& user_id
);
40 bool operator==(const UserContext
& context
) const;
41 bool operator!=(const UserContext
& context
) const;
43 const std::string
& GetUserID() const;
44 const std::string
& GetGaiaID() const;
45 const Key
* GetKey() const;
47 const std::string
& GetAuthCode() const;
48 const std::string
& GetUserIDHash() const;
49 bool IsUsingOAuth() const;
50 AuthFlow
GetAuthFlow() const;
51 user_manager::UserType
GetUserType() const;
52 const std::string
& GetPublicSessionLocale() const;
53 const std::string
& GetPublicSessionInputMethod() const;
55 bool HasCredentials() const;
57 void SetUserID(const std::string
& user_id
);
58 void SetGaiaID(const std::string
& gaia_id
);
59 void SetKey(const Key
& key
);
60 void SetAuthCode(const std::string
& auth_code
);
61 void SetUserIDHash(const std::string
& user_id_hash
);
62 void SetIsUsingOAuth(bool is_using_oauth
);
63 void SetAuthFlow(AuthFlow auth_flow
);
64 void SetUserType(user_manager::UserType user_type
);
65 void SetPublicSessionLocale(const std::string
& locale
);
66 void SetPublicSessionInputMethod(const std::string
& input_method
);
74 std::string auth_code_
;
75 std::string user_id_hash_
;
78 user_manager::UserType user_type_
;
79 std::string public_session_locale_
;
80 std::string public_session_input_method_
;
83 } // namespace chromeos
85 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_