/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "squid.h"
#include "acl/Gadgets.h"
+#include "auth/Config.h"
#include "auth/CredentialsCache.h"
#include "base/RunnersRegistry.h"
#include "Debug.h"
#include "event.h"
-#include "SquidConfig.h"
-#include "SquidTime.h"
namespace Auth {
{}
virtual ~CredentialCacheRr() {
- debugs(29, 5, "Terminating username cache: " << name);
+ debugs(29, 5, "Terminating Auth credentials cache: " << name);
// invalidate the CBDATA reference.
// causes Auth::*::User::Cache() to produce nil / invalid pointer
delete whichCache.get();
}
virtual void endingShutdown() override {
- debugs(29, 5, "Clearing username cache: " << name);
+ debugs(29, 5, "Clearing Auth credentials cache: " << name);
whichCache->reset();
}
virtual void syncConfig() override {
- if (!whichCache.valid())
- return;
-
- debugs(29, 5, "Reconfiguring username cache: " << name);
+ debugs(29, 5, "Reconfiguring Auth credentials cache: " << name);
whichCache->doConfigChangeCleanup();
}
gcScheduled_(false),
cacheCleanupEventName(prettyEvName)
{
- debugs(29, 5, "initializing " << name << " username cache");
+ debugs(29, 5, "initializing " << name << " credentials cache");
RegisterRunner(new Auth::CredentialCacheRr(name, this));
}
CredentialsCache::cleanup()
{
// cache entries with expiretime <= expirationTime are to be evicted
- const time_t expirationTime = current_time.tv_sec - ::Config.authenticateTTL;
+ const time_t expirationTime = current_time.tv_sec - Auth::TheConfig.credentialsTtl;
const auto end = store_.end();
for (auto i = store_.begin(); i != end;) {
++i;
}
}
+ gcScheduled_ = false;
scheduleCleanup();
}
void
-CredentialsCache::insert(Auth::User::Pointer anAuth_user)
+CredentialsCache::insert(const SBuf &userKey, Auth::User::Pointer anAuth_user)
{
- debugs(29, 6, "adding " << anAuth_user->userKey());
- store_[anAuth_user->userKey()] = anAuth_user;
+ debugs(29, 6, "adding " << userKey << " (" << anAuth_user->username() << ")");
+ store_[userKey] = anAuth_user;
scheduleCleanup();
}
if (!gcScheduled_ && store_.size()) {
gcScheduled_ = true;
eventAdd(cacheCleanupEventName, &CredentialsCache::Cleanup,
- this, ::Config.authenticateGCInterval, 1);
+ this, Auth::TheConfig.garbageCollectInterval, 1);
}
}