From 0a608df9603f8ebead928362ac5fceb6b4552277 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 2 May 2010 21:10:08 +1200 Subject: [PATCH] Merge validate wrapper into AuthuerRequest --- src/auth/AclProxyAuth.cc | 3 ++- src/auth/UserRequest.cc | 18 ++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/auth/AclProxyAuth.cc b/src/auth/AclProxyAuth.cc index 44dd49d769..0717556287 100644 --- a/src/auth/AclProxyAuth.cc +++ b/src/auth/AclProxyAuth.cc @@ -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 */ diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index 4b4a2b5dc8..16e6d43d63 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -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 */ -- 2.47.3