]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge validate wrapper into AuthuerRequest
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 May 2010 09:10:08 +0000 (21:10 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 May 2010 09:10:08 +0000 (21:10 +1200)
src/auth/AclProxyAuth.cc
src/auth/UserRequest.cc

index 44dd49d769d8ad799caea462e4284125ecdc98e6..0717556287c243235e0ec3594793c1c204e4565f 100644 (file)
@@ -142,6 +142,7 @@ ProxyAuthLookup::checkForAsync(ACLChecklist *cl)const
     debugs(28, 3, HERE << "checking password via authenticator");
 
     /* make sure someone created auth_user_request for us */
+    assert(checklist->auth_user_request != NULL);
     assert(checklist->auth_user_request->valid());
     checklist->auth_user_request->start(LookupDone, checklist);
 }
@@ -156,7 +157,7 @@ ProxyAuthLookup::LookupDone(void *data, char *result)
     if (result != NULL)
         fatal("AclLookupProxyAuthDone: Old code floating around somewhere.\nMake clean and if that doesn't work, report a bug to the squid developers.\n");
 
-    if (!checklist->auth_user_request->valid() || checklist->conn() == NULL) {
+    if (checklist->auth_user_request == NULL || !checklist->auth_user_request->valid() || checklist->conn() == NULL) {
         /* credentials could not be checked either way
          * restart the whole process */
         /* OR the connection was closed, there's no way to continue */
index 4b4a2b5dc82e4708c78c9f913e201ef684326a4c..16e6d43d63aa15f67e7bb10e3b84d3cf13826ecb 100644 (file)
@@ -75,18 +75,13 @@ AuthUserRequest::start(RH * handler, void *data)
 }
 
 bool
-AuthUserRequest::valid()
+AuthUserRequest::valid() const
 {
     debugs(29, 9, HERE << "Validating AuthUserRequest '" << this << "'.");
 
-    if (getRaw() == NULL) {
-        debugs(29, 4, HERE << "AuthUserRequest was NULL!");
-        return 0;
-    }
-
     if (user() == NULL) {
         debugs(29, 4, HERE << "No associated AuthUser data");
-        return 0;
+        return false;
     }
 
     if (user()->auth_type == AUTH_UNKNOWN) {
@@ -205,7 +200,7 @@ authenticateAuthUserRequestIPCount(AuthUserRequest::Pointer auth_user_request)
 int
 authenticateUserAuthenticated(AuthUserRequest::Pointer auth_user_request)
 {
-    if (!auth_user_request->valid())
+    if (auth_user_request == NULL || !auth_user_request->valid())
         return 0;
 
     return auth_user_request->authenticated();
@@ -373,10 +368,9 @@ AuthUserRequest::authenticate(AuthUserRequest::Pointer * auth_user_request, http
             debugs(29, 4, "authenticateAuthenticate: no connection authentication type");
 
             *auth_user_request = AuthConfig::CreateAuthUser(proxy_auth);
-            if (!(*auth_user_request)->valid()) {
-                if (*auth_user_request == NULL)
-                    return AUTH_ACL_CHALLENGE;
-
+            if (*auth_user_request == NULL)
+                return AUTH_ACL_CHALLENGE;
+            else if (!(*auth_user_request)->valid()) {
                 /* the decode might have left a username for logging, or a message to
                  * the user */