2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_AUTH_USER_H
10 #define SQUID_AUTH_USER_H
14 #include "auth/CredentialState.h"
15 #include "auth/forward.h"
16 #include "auth/Type.h"
17 #include "base/CbcPointer.h"
18 #include "base/RefCount.h"
20 #include "ip/Address.h"
22 #include "sbuf/SBuf.h"
30 * This is the main user related structure. It stores user-related data,
31 * and is persistent across requests. It can even persist across
32 * multiple external authentications. One major benefit of preserving this
33 * structure is the cached ACL match results. This structure, is private to
34 * the authentication framework.
36 class User
: public RefCountable
39 typedef RefCount
<User
> Pointer
;
42 User(Auth::SchemeConfig
*, const char *requestRealm
);
46 /* extra fields for proxy_auth */
47 /** \deprecated this determines what scheme owns the user data. */
49 /** the config for this user */
50 Auth::SchemeConfig
*config
;
51 dlink_list proxy_match_cache
;
55 /// list of key=value pairs the helper produced
59 static SBuf
BuildUserKey(const char *username
, const char *realm
);
61 void absorb(Auth::User::Pointer from
);
62 char const *username() const { return username_
; }
63 void username(char const *); ///< set stored username and userKey
65 // NP: key is set at the same time as username_. Until then both are empty/NULL.
66 const SBuf
userKey() const {return userKey_
;}
69 * How long these credentials are still valid for.
70 * Negative numbers means already expired.
72 virtual int32_t ttl() const = 0;
74 /* Manage list of IPs using this username */
76 void removeIp(Ip::Address
);
77 void addIp(Ip::Address
);
79 /// add the Auth::User to the protocol-specific username cache.
80 virtual void addToNameCache() = 0;
81 static void CredentialsCacheStats(StoreEntry
* output
);
83 // userKey ->Auth::User::Pointer cache
84 // must be reimplemented in subclasses
85 static CbcPointer
<Auth::CredentialsCache
> Cache();
87 CredentialState
credentials() const;
88 void credentials(CredentialState
);
92 * The current state these credentials are in:
95 * Pending helper result
96 * Handshake happening in stateful auth.
99 CredentialState credentials_state
;
104 * The username_ memory will be allocated via
105 * xstrdup(). It is our responsibility.
107 const char *username_
;
110 * A realm for the user depending on request, designed to identify users,
111 * with the same username and different authentication domains.
116 * A Unique key for the user, consist by username and requestRealm_
120 /** what ip addresses has this user been seen at?, plus a list length cache */
126 #endif /* USE_AUTH */
127 #endif /* SQUID_AUTH_USER_H */