User.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_SRC_AUTH_USER_H
10 #define SQUID_SRC_AUTH_USER_H
11 
12 #if USE_AUTH
13 
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"
19 #include "dlink.h"
20 #include "ip/Address.h"
21 #include "Notes.h"
22 #include "sbuf/SBuf.h"
23 
24 class StoreEntry;
25 
26 namespace Auth
27 {
28 
36 class User : public RefCountable
37 {
38 public:
40 
41 protected:
42  User(Auth::SchemeConfig *, const char *requestRealm);
43 public:
44  ~User() override;
45 
46  /* extra fields for proxy_auth */
52  size_t ipcount;
53  long expiretime;
54 
57 
58 public:
59  static SBuf BuildUserKey(const char *username, const char *realm);
60 
61  void absorb(Auth::User::Pointer from);
62  char const *username() const { return username_; }
63  void username(char const *);
64 
65  // NP: key is set at the same time as username_. Until then both are empty/NULL.
66  const SBuf userKey() const {return userKey_;}
67 
72  virtual int32_t ttl() const = 0;
73 
74  /* Manage list of IPs using this username */
75  void clearIp();
76  void removeIp(Ip::Address);
77  void addIp(Ip::Address);
78 
80  virtual void addToNameCache() = 0;
81  static void CredentialsCacheStats(StoreEntry * output);
82 
83  // userKey ->Auth::User::Pointer cache
84  // must be reimplemented in subclasses
86 
89 
90 private:
100 
101 private:
107  const char *username_;
108 
114 
119 
122 };
123 
124 } // namespace Auth
125 
126 #endif /* USE_AUTH */
127 #endif /* SQUID_SRC_AUTH_USER_H */
128 
virtual int32_t ttl() const =0
static CbcPointer< Auth::CredentialsCache > Cache()
HTTP Authentication.
Definition: Config.h:18
~User() override
Definition: User.cc:120
static SBuf BuildUserKey(const char *username, const char *realm)
Definition: User.cc:229
Definition: SBuf.h:93
const SBuf userKey() const
Definition: User.h:66
SBuf requestRealm_
Definition: User.h:113
static void CredentialsCacheStats(StoreEntry *output)
Definition: User.cc:243
Type
Definition: Type.h:17
void clearIp()
Definition: User.cc:139
NotePairs notes
list of key=value pairs the helper produced
Definition: User.h:56
User(Auth::SchemeConfig *, const char *requestRealm)
Definition: User.cc:23
const char * username() const
Definition: User.h:62
Auth::SchemeConfig * config
Definition: User.h:50
virtual void addToNameCache()=0
add the Auth::User to the protocol-specific username cache.
long expiretime
Definition: User.h:53
void removeIp(Ip::Address)
Definition: User.cc:161
dlink_list ip_list
Definition: User.h:121
RefCount< User > Pointer
Definition: User.h:39
CredentialState credentials() const
Definition: User.cc:38
size_t ipcount
Definition: User.h:52
const char * username_
Definition: User.h:107
SBuf userKey_
Definition: User.h:118
void addIp(Ip::Address)
Definition: User.cc:184
void absorb(Auth::User::Pointer from)
Definition: User.cc:59
Auth::Type auth_type
Definition: User.h:48
CredentialState credentials_state
Definition: User.h:99
dlink_list proxy_match_cache
Definition: User.h:51

 

Introduction

Documentation

Support

Miscellaneous