]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove old authenticateValidateUser wrapper
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 May 2010 06:58:12 +0000 (18:58 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 May 2010 06:58:12 +0000 (18:58 +1200)
src/auth/AclProxyAuth.cc
src/auth/UserRequest.cc
src/auth/UserRequest.h

index 0eed9c8b75ad88a1a210b2b94a8297d0202bcb27..44dd49d769d8ad799caea462e4284125ecdc98e6 100644 (file)
@@ -139,16 +139,11 @@ ProxyAuthLookup::checkForAsync(ACLChecklist *cl)const
     ACLFilledChecklist *checklist = Filled(cl);
 
     checklist->asyncInProgress(true);
-    debugs(28, 3, "ACLChecklist::checkForAsync: checking password via authenticator");
+    debugs(28, 3, HERE << "checking password via authenticator");
 
-    AuthUserRequest::Pointer auth_user_request;
     /* make sure someone created auth_user_request for us */
-    assert(checklist->auth_user_request != NULL);
-    auth_user_request = checklist->auth_user_request;
-
-    int validated = authenticateValidateUser(auth_user_request);
-    assert(validated);
-    auth_user_request->start(LookupDone, checklist);
+    assert(checklist->auth_user_request->valid());
+    checklist->auth_user_request->start(LookupDone, checklist);
 }
 
 void
@@ -161,7 +156,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 (!authenticateValidateUser(checklist->auth_user_request) || checklist->conn() == NULL) {
+    if (!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 7ca5e31c879e67bbc1dfad55b0e17a28e37f5f33..4b4a2b5dc82e4708c78c9f913e201ef684326a4c 100644 (file)
@@ -74,45 +74,36 @@ AuthUserRequest::start(RH * handler, void *data)
     module_start(handler, data);
 }
 
-/*
- * Check a auth_user pointer for validity. Does not check passwords, just data
- * sensability. Broken or Unknown auth_types are not valid for use...
- */
-
-int
-authenticateValidateUser(AuthUserRequest::Pointer auth_user_request)
+bool
+AuthUserRequest::valid()
 {
-    debugs(29, 9, "authenticateValidateUser: Validating Auth_user request '" << auth_user_request << "'.");
+    debugs(29, 9, HERE << "Validating AuthUserRequest '" << this << "'.");
 
-    if (auth_user_request.getRaw() == NULL) {
-        debugs(29, 4, "authenticateValidateUser: Auth_user_request was NULL!");
+    if (getRaw() == NULL) {
+        debugs(29, 4, HERE << "AuthUserRequest was NULL!");
         return 0;
     }
 
-    if (auth_user_request->user() == NULL) {
-        debugs(29, 4, "authenticateValidateUser: No associated auth_user structure");
+    if (user() == NULL) {
+        debugs(29, 4, HERE << "No associated AuthUser data");
         return 0;
     }
 
-    if (auth_user_request->user()->auth_type == AUTH_UNKNOWN) {
-        debugs(29, 4, "authenticateValidateUser: Auth_user '" << auth_user_request->user() << "' uses unknown scheme.");
-        return 0;
+    if (user()->auth_type == AUTH_UNKNOWN) {
+        debugs(29, 4, HERE << "AuthUser '" << user() << "' uses unknown scheme.");
+        return false;
     }
 
-    if (auth_user_request->user()->auth_type == AUTH_BROKEN) {
-        debugs(29, 4, "authenticateValidateUser: Auth_user '" << auth_user_request->user() << "' is broken for it's scheme.");
-        return 0;
+    if (user()->auth_type == AUTH_BROKEN) {
+        debugs(29, 4, HERE << "AuthUser '" << user() << "' is broken for it's scheme.");
+        return false;
     }
 
     /* any other sanity checks that we need in the future */
 
-    /* Thus should a module call to something like authValidate */
-
     /* finally return ok */
-    debugs(29, 5, "authenticateValidateUser: Validated Auth_user request '" << auth_user_request << "'.");
-
-    return 1;
-
+    debugs(29, 5, HERE << "Validated. AuthUserRequest '" << this << "'.");
+    return true;
 }
 
 void *
@@ -214,7 +205,7 @@ authenticateAuthUserRequestIPCount(AuthUserRequest::Pointer auth_user_request)
 int
 authenticateUserAuthenticated(AuthUserRequest::Pointer auth_user_request)
 {
-    if (!authenticateValidateUser(auth_user_request))
+    if (!auth_user_request->valid())
         return 0;
 
     return auth_user_request->authenticated();
@@ -382,7 +373,7 @@ AuthUserRequest::authenticate(AuthUserRequest::Pointer * auth_user_request, http
             debugs(29, 4, "authenticateAuthenticate: no connection authentication type");
 
             *auth_user_request = AuthConfig::CreateAuthUser(proxy_auth);
-            if (!authenticateValidateUser(*auth_user_request)) {
+            if (!(*auth_user_request)->valid()) {
                 if (*auth_user_request == NULL)
                     return AUTH_ACL_CHALLENGE;
 
index c8dad5cdfcae5d17ba5f3c44f9b137502f49253c..58cff83f2da0bae41493dd0861bcb63764fc2065 100644 (file)
@@ -97,6 +97,19 @@ public:
      \retval false     Timeouts on cached credentials have occurred or for any reason the credentials are not valid.
      */
     virtual int authenticated() const = 0;
+
+    /**
+     * Check a auth_user pointer for validity.
+     * Does not check passwords, just data sensability. Broken or Unknown auth_types are not valid for use...
+     *
+     * \retval false    User credentials are missing.
+     * \retval false    User credentials use an unknown scheme type.
+     * \retval false    User credentials are broken for their scheme.
+     *
+     * \retval true    User credentials exist and may be able to authenticate.
+     */
+    bool valid() const;
+
     virtual void authenticate(HttpRequest * request, ConnStateData * conn, http_hdr_type type) = 0;
     /* template method */
     virtual int module_direction() = 0;
@@ -186,8 +199,6 @@ extern int authenticateDirection(AuthUserRequest::Pointer);
 /// \ingroup AuthAPI
 /// See AuthUserRequest::authenticated()
 extern int authenticateUserAuthenticated(AuthUserRequest::Pointer);
-/// \ingroup AuthAPI
-extern int authenticateValidateUser(AuthUserRequest::Pointer);
 
 
 #endif /* SQUID_AUTHUSERREQUEST_H */