From: Amos Jeffries Date: Tue, 20 Dec 2016 09:12:07 +0000 (+1300) Subject: Shuffle other auth config options to Auth::Config X-Git-Tag: M-staged-PR71~333^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5db226c8872be44e7e025d884ffdc6a0c778e4f4;p=thirdparty%2Fsquid.git Shuffle other auth config options to Auth::Config Also, remove some unnecessary includes --- diff --git a/src/SquidConfig.h b/src/SquidConfig.h index 416c386c48..72da8bb7c4 100644 --- a/src/SquidConfig.h +++ b/src/SquidConfig.h @@ -198,9 +198,6 @@ public: Helper::ChildConfig redirectChildren; Helper::ChildConfig storeIdChildren; - time_t authenticateGCInterval; - time_t authenticateTTL; - time_t authenticateIpTTL; struct { char *surrogate_id; diff --git a/src/auth/Config.h b/src/auth/Config.h index 665e5bd2b3..5a684c65e9 100644 --- a/src/auth/Config.h +++ b/src/auth/Config.h @@ -29,6 +29,15 @@ public: /// the ACL list for auth_schemes directives acl_access *schemeAccess = nullptr; + + /// the authenticate_cache_garbage_interval + time_t authenticateGCInterval; + + /// the authenticate_ttl + time_t authenticateTTL; + + /// the authenticate_ip_ttl + time_t authenticateIpTTL; }; extern Auth::Config TheConfig; diff --git a/src/auth/CredentialsCache.cc b/src/auth/CredentialsCache.cc index 3a8ee013cd..8e9ae4b5fc 100644 --- a/src/auth/CredentialsCache.cc +++ b/src/auth/CredentialsCache.cc @@ -10,12 +10,11 @@ #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 { @@ -85,7 +84,7 @@ void 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.authenticateTTL; const auto end = store_.end(); for (auto i = store_.begin(); i != end;) { @@ -133,7 +132,7 @@ CredentialsCache::scheduleCleanup() if (!gcScheduled_ && store_.size()) { gcScheduled_ = true; eventAdd(cacheCleanupEventName, &CredentialsCache::Cleanup, - this, ::Config.authenticateGCInterval, 1); + this, Auth::TheConfig.authenticateGCInterval, 1); } } diff --git a/src/auth/User.cc b/src/auth/User.cc index 279f648c37..afc82eca29 100644 --- a/src/auth/User.cc +++ b/src/auth/User.cc @@ -11,14 +11,13 @@ #include "squid.h" #include "acl/Acl.h" #include "acl/Gadgets.h" +#include "auth/Config.h" #include "auth/CredentialsCache.h" #include "auth/Gadgets.h" -#include "auth/SchemeConfig.h" #include "auth/User.h" #include "auth/UserRequest.h" #include "event.h" #include "globals.h" -#include "SquidConfig.h" #include "SquidTime.h" #include "Store.h" @@ -201,7 +200,7 @@ Auth::User::addIp(Ip::Address ipaddr) /* This ip has already been seen. */ found = 1; /* update IP ttl */ - ipdata->ip_expiretime = squid_curtime + ::Config.authenticateIpTTL; + ipdata->ip_expiretime = squid_curtime + Auth::TheConfig.authenticateIpTTL; } else if (ipdata->ip_expiretime <= squid_curtime) { /* This IP has expired - remove from the seen list */ dlinkDelete(&ipdata->node, &ip_list); @@ -218,7 +217,7 @@ Auth::User::addIp(Ip::Address ipaddr) return; /* This ip is not in the seen list */ - ipdata = new AuthUserIP(ipaddr, squid_curtime + ::Config.authenticateIpTTL); + ipdata = new AuthUserIP(ipaddr, squid_curtime + Auth::TheConfig.authenticateIpTTL); dlinkAddTail(ipdata, &ipdata->node, &ip_list); @@ -258,7 +257,7 @@ Auth::User::CredentialsCacheStats(StoreEntry *output) Auth::Type_str[auth_user->auth_type], CredentialState_str[auth_user->credentials()], auth_user->ttl(), - static_cast(auth_user->expiretime - squid_curtime + ::Config.authenticateTTL), + static_cast(auth_user->expiretime - squid_curtime + Auth::TheConfig.authenticateTTL), auth_user->username(), SQUIDSBUFPRINT(auth_user->userKey()) ); diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index c899349913..386bd3d87e 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -23,7 +23,6 @@ #include "HttpReply.h" #include "HttpRequest.h" #include "MemBuf.h" -#include "SquidConfig.h" /* Generic Functions */ diff --git a/src/auth/basic/User.cc b/src/auth/basic/User.cc index 2b336726ec..5f541d3a38 100644 --- a/src/auth/basic/User.cc +++ b/src/auth/basic/User.cc @@ -9,10 +9,9 @@ #include "squid.h" #include "auth/basic/Config.h" #include "auth/basic/User.h" +#include "auth/Config.h" #include "auth/CredentialsCache.h" #include "Debug.h" -#include "SquidConfig.h" -#include "SquidTime.h" Auth::Basic::User::User(Auth::SchemeConfig *aConfig, const char *aRequestRealm) : Auth::User(aConfig, aRequestRealm), @@ -33,7 +32,7 @@ Auth::Basic::User::ttl() const return -1; // TTL is obsolete NOW. int32_t basic_ttl = expiretime - squid_curtime + static_cast(config)->credentialsTTL; - int32_t global_ttl = static_cast(expiretime - squid_curtime + ::Config.authenticateTTL); + int32_t global_ttl = static_cast(expiretime - squid_curtime + Auth::TheConfig.authenticateTTL); return min(basic_ttl, global_ttl); } diff --git a/src/auth/digest/User.cc b/src/auth/digest/User.cc index 4c0a9cbd87..4a3594d2da 100644 --- a/src/auth/digest/User.cc +++ b/src/auth/digest/User.cc @@ -7,13 +7,12 @@ */ #include "squid.h" +#include "auth/Config.h" #include "auth/CredentialsCache.h" #include "auth/digest/Config.h" #include "auth/digest/User.h" #include "Debug.h" #include "dlink.h" -#include "SquidConfig.h" -#include "SquidTime.h" Auth::Digest::User::User(Auth::SchemeConfig *aConfig, const char *aRequestRealm) : Auth::User(aConfig, aRequestRealm), @@ -40,7 +39,7 @@ Auth::Digest::User::~User() int32_t Auth::Digest::User::ttl() const { - int32_t global_ttl = static_cast(expiretime - squid_curtime + ::Config.authenticateTTL); + int32_t global_ttl = static_cast(expiretime - squid_curtime + Auth::TheConfig.authenticateTTL); /* find the longest lasting nonce. */ int32_t latest_nonce = -1; diff --git a/src/cf.data.pre b/src/cf.data.pre index 525a2e9ff3..bc93ec2102 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -736,9 +736,10 @@ ENDIF DOC_END NAME: authenticate_cache_garbage_interval +IFDEF: USE_AUTH TYPE: time_t DEFAULT: 1 hour -LOC: Config.authenticateGCInterval +LOC: Auth::TheConfig.authenticateGCInterval DOC_START The time period between garbage collection across the username cache. This is a trade-off between memory utilization (long intervals - say @@ -747,9 +748,10 @@ DOC_START DOC_END NAME: authenticate_ttl +IFDEF: USE_AUTH TYPE: time_t DEFAULT: 1 hour -LOC: Config.authenticateTTL +LOC: Auth::TheConfig.authenticateTTL DOC_START The time a user & their credentials stay in the logged in user cache since their last request. When the garbage @@ -758,8 +760,9 @@ DOC_START DOC_END NAME: authenticate_ip_ttl +IFDEF: USE_AUTH TYPE: time_t -LOC: Config.authenticateIpTTL +LOC: Auth::TheConfig.authenticateIpTTL DEFAULT: 1 second DOC_START If you use proxy authentication and the 'max_user_ip' ACL,