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 Key* GetKey() const;
46 const std::string& GetAuthCode() const;
47 const std::string& GetUserIDHash() const;
48 bool IsUsingOAuth() const;
49 AuthFlow GetAuthFlow() const;
50 user_manager::UserType GetUserType() const;
51 const std::string& GetPublicSessionLocale() const;
52 const std::string& GetPublicSessionInputMethod() const;
54 bool HasCredentials() const;
56 void SetUserID(const std::string& user_id);
57 void SetKey(const Key& key);
58 void SetAuthCode(const std::string& auth_code);
59 void SetUserIDHash(const std::string& user_id_hash);
60 void SetIsUsingOAuth(bool is_using_oauth);
61 void SetAuthFlow(AuthFlow auth_flow);
62 void SetUserType(user_manager::UserType user_type);
63 void SetPublicSessionLocale(const std::string& locale);
64 void SetPublicSessionInputMethod(const std::string& input_method);
71 std::string auth_code_;
72 std::string user_id_hash_;
75 user_manager::UserType user_type_;
76 std::string public_session_locale_;
77 std::string public_session_input_method_;
80 } // namespace chromeos
82 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_