]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: remove some duplicate auth code (#2097)
authorAmos Jeffries <yadij@users.noreply.github.com>
Mon, 23 Jun 2025 23:11:47 +0000 (23:11 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 25 Jun 2025 16:07:23 +0000 (16:07 +0000)
src/auth/SchemeConfig.cc
src/auth/SchemeConfig.h
src/auth/basic/Config.cc
src/auth/digest/Config.cc
src/auth/negotiate/Config.cc
src/auth/negotiate/Config.h
src/auth/ntlm/Config.cc
src/auth/ntlm/Config.h

index 99ce31a451aed98a950964bae58dd4364f245506..f0be38378f6aa8c15b803c83dbd69dcac3c36ead 100644 (file)
@@ -179,6 +179,12 @@ Auth::SchemeConfig::done()
     keyExtrasLine.clean();
 }
 
+bool
+Auth::SchemeConfig::configured() const
+{
+    return (authenticateProgram && authenticateChildren.n_max != 0);
+}
+
 bool
 Auth::SchemeConfig::isCP1251EncodingAllowed(const HttpRequest *request)
 {
index 028ef034dfacf521f1f573f31c049e8cc4dd521f..c07b381e4453248bd5583fad8d6d7f2ba6b0f854 100644 (file)
@@ -94,7 +94,7 @@ public:
      \retval false  Not configured or Configuration Error.
      *          No other module functions except Shutdown/Dump/Parse/FreeConfig will be called by Squid.
      */
-    virtual bool configured() const = 0;
+    virtual bool configured() const;
 
     /**
      * Shutdown just the auth helpers.
index d3ebd5855bc17cae5e6507b1130cc9e456929d88..2b9f7c28f21ef691253cff818a78b664cfc37f54 100644 (file)
@@ -57,13 +57,7 @@ Auth::Basic::Config::active() const
 bool
 Auth::Basic::Config::configured() const
 {
-    if ((authenticateProgram != nullptr) && (authenticateChildren.n_max != 0) && !realm.isEmpty()) {
-        debugs(29, 9, "returning configured");
-        return true;
-    }
-
-    debugs(29, 9, "returning unconfigured");
-    return false;
+    return (SchemeConfig::configured() && !realm.isEmpty());
 }
 
 const char *
index f39720841494783dab586ae63e5154c20e2c9fd0..bcd6e84b50b03a81625dbb44c892c472cd904f16 100644 (file)
@@ -474,12 +474,7 @@ Auth::Digest::Config::active() const
 bool
 Auth::Digest::Config::configured() const
 {
-    if ((authenticateProgram != nullptr) &&
-            (authenticateChildren.n_max != 0) &&
-            !realm.isEmpty() && (noncemaxduration > -1))
-        return true;
-
-    return false;
+    return (SchemeConfig::configured() && !realm.isEmpty() && noncemaxduration > -1);
 }
 
 /* add the [www-|Proxy-]authenticate header on a 407 or 401 reply */
index 34329f2fd299511c28d6f9f90280c77a4061a85d..8644d23e92cae899d86f3c1061098380537c4454 100644 (file)
@@ -120,18 +120,6 @@ Auth::Negotiate::Config::active() const
     return authnegotiate_initialised == 1;
 }
 
-bool
-Auth::Negotiate::Config::configured() const
-{
-    if (authenticateProgram && (authenticateChildren.n_max != 0)) {
-        debugs(29, 9, "returning configured");
-        return true;
-    }
-
-    debugs(29, 9, "returning unconfigured");
-    return false;
-}
-
 void
 Auth::Negotiate::Config::fixHeader(Auth::UserRequest::Pointer auth_user_request, HttpReply *rep, Http::HdrType reqType, HttpRequest * request)
 {
index 825dc7b5ef51845a7b8956878ad64fadd89136b4..88991f2d990ce755f6afdff8afc58d163650f7b5 100644 (file)
@@ -26,7 +26,6 @@ class Config : public Auth::SchemeConfig
 {
 public:
     bool active() const override;
-    bool configured() const override;
     Auth::UserRequest::Pointer decode(char const *proxy_auth, const HttpRequest *request, const char *requestRealm) override;
     void done() override;
     void rotateHelpers() override;
index b577c66a8ae8eb4de9b86e753b49e056dc692c5d..2af76b9d49d6d5df56914d27b34565fdaa3d2c2a 100644 (file)
@@ -119,18 +119,6 @@ Auth::Ntlm::Config::active() const
     return authntlm_initialised == 1;
 }
 
-bool
-Auth::Ntlm::Config::configured() const
-{
-    if ((authenticateProgram != nullptr) && (authenticateChildren.n_max != 0)) {
-        debugs(29, 9, "returning configured");
-        return true;
-    }
-
-    debugs(29, 9, "returning unconfigured");
-    return false;
-}
-
 /* NTLM Scheme */
 
 void
index 4b216bf5d2f5e2741da49f56652a38c469c1216e..4cd493497af91228430b503bda13795cdeb00af9 100644 (file)
@@ -29,7 +29,6 @@ class Config : public Auth::SchemeConfig
 {
 public:
     bool active() const override;
-    bool configured() const override;
     Auth::UserRequest::Pointer decode(char const *proxy_auth, const HttpRequest *request, const char *requestRealm) override;
     void done() override;
     void rotateHelpers() override;