CredentialsCache.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_CREDENTIALSCACHE_H
10 #define SQUID_SRC_AUTH_CREDENTIALSCACHE_H
11 
12 #include "auth/User.h"
13 #include "cbdata.h"
14 #include "sbuf/Algorithms.h"
15 
16 #include <unordered_map>
17 
18 namespace Auth {
19 
22 {
24 
25 public:
26  explicit CredentialsCache(const char *name, const char * const eventName);
27 
28  ~CredentialsCache() = default;
29  CredentialsCache(const CredentialsCache&) = delete;
31 
33  Auth::User::Pointer lookup(const SBuf &userKey) const;
34 
36  void insert(const SBuf &userKey, const Auth::User::Pointer &anAuth_user);
37 
39  void reset() { store_.clear(); }
40 
42  size_t size() const { return store_.size(); }
43 
48  static void Cleanup(void *);
49 
51  void cleanup();
52 
58  void doConfigChangeCleanup();
59 
61  std::vector<Auth::User::Pointer> sortedUsersList() const;
62 
63 private:
64  void scheduleCleanup();
65 
68 
70  typedef std::unordered_map<SBuf, Auth::User::Pointer> StoreType;
72 
73  // c-string raw pointer used as event name
74  const char * const cacheCleanupEventName;
75 };
76 
77 } /* namespace Auth */
78 
79 #endif /* SQUID_SRC_AUTH_CREDENTIALSCACHE_H */
80 
Auth::User::Pointer lookup(const SBuf &userKey) const
HTTP Authentication.
Definition: Config.h:18
bool gcScheduled_
whether a cleanup (garbage collection) event has been scheduled
Definition: SBuf.h:93
void insert(const SBuf &userKey, const Auth::User::Pointer &anAuth_user)
add an user to the cache with the provided key
std::unordered_map< SBuf, Auth::User::Pointer > StoreType
key is User::userKey(), mapped value is User::Pointer
CredentialsCache & operator=(const CredentialsCache &)=delete
void reset()
clear cache
static void Cleanup(void *)
const char *const cacheCleanupEventName
CredentialsCache(const char *name, const char *const eventName)
std::vector< Auth::User::Pointer > sortedUsersList() const
void cleanup()
cache garbage collection, removes timed-out entries
Cache of Auth::User credentials, keyed by Auth::User::userKey.
CBDATA_CLASS(CredentialsCache)

 

Introduction

Documentation

Support

Miscellaneous