2 * Copyright (C) 1996-2015 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/Type.h"
16 #include "base/CbcPointer.h"
17 #include "base/RefCount.h"
19 #include "ip/Address.h"
33 * This is the main user related structure. It stores user-related data,
34 * and is persistent across requests. It can even persist across
35 * multiple external authentications. One major benefit of preserving this
36 * structure is the cached ACL match results. This structure, is private to
37 * the authentication framework.
39 class User
: public RefCountable
42 typedef RefCount
<User
> Pointer
;
44 /* extra fields for proxy_auth */
45 /* auth_type and auth_module are deprecated. Do Not add new users of these fields.
46 * Aim to remove shortly
48 /** \deprecated this determines what scheme owns the user data. */
50 /** the config for this user */
52 dlink_list proxy_match_cache
;
56 /// list of key=value pairs the helper produced
60 static SBuf
BuildUserKey(const char *username
, const char *realm
);
62 void absorb(Auth::User::Pointer from
);
64 char const *username() const { return username_
; }
65 void username(char const *); ///< set stored username and userKey
67 // NP: key is set at the same time as username_. Until then both are empty/NULL.
68 const char *userKey() {return !userKey_
.isEmpty() ? userKey_
.c_str() : NULL
;}
70 const SBuf
SBufUserKey() const {return userKey_
;}
73 * How long these credentials are still valid for.
74 * Negative numbers means already expired.
76 virtual int32_t ttl() const = 0;
78 /* Manage list of IPs using this username */
80 void removeIp(Ip::Address
);
81 void addIp(Ip::Address
);
83 /// add the Auth::User to the protocol-specific username cache.
84 virtual void addToNameCache() = 0;
85 static void UsernameCacheStats(StoreEntry
* output
);
87 // userKey ->Auth::User::Pointer cache
88 // must be reimplemented in subclasses
89 static CbcPointer
<Auth::UserNameCache
> Cache();
91 CredentialState
credentials() const;
92 void credentials(CredentialState
);
96 * The current state these credentials are in:
99 * Pending helper result
100 * Handshake happening in stateful auth.
103 CredentialState credentials_state
;
106 User(Auth::Config
*, const char *requestRealm
);
111 * The username_ memory will be allocated via
112 * xstrdup(). It is our responsibility.
114 const char *username_
;
117 * A realm for the user depending on request, designed to identify users,
118 * with the same username and different authentication domains.
123 * A Unique key for the user, consist by username and requestRealm_
127 /** what ip addresses has this user been seen at?, plus a list length cache */
133 #endif /* USE_AUTH */
134 #endif /* SQUID_AUTH_USER_H */