From: Amos Jeffries Date: Sun, 2 May 2010 06:58:12 +0000 (+1200) Subject: Remove old authenticateValidateUser wrapper X-Git-Tag: SQUID_3_2_0_1~167^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e39494f50466911ce62380034a70080984d3bae;p=thirdparty%2Fsquid.git Remove old authenticateValidateUser wrapper --- diff --git a/src/auth/AclProxyAuth.cc b/src/auth/AclProxyAuth.cc index 0eed9c8b75..44dd49d769 100644 --- a/src/auth/AclProxyAuth.cc +++ b/src/auth/AclProxyAuth.cc @@ -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 */ diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index 7ca5e31c87..4b4a2b5dc8 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -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; diff --git a/src/auth/UserRequest.h b/src/auth/UserRequest.h index c8dad5cdfc..58cff83f2d 100644 --- a/src/auth/UserRequest.h +++ b/src/auth/UserRequest.h @@ -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 */