]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert Negotiate to new cache
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 3 Sep 2015 16:21:31 +0000 (18:21 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 3 Sep 2015 16:21:31 +0000 (18:21 +0200)
src/auth/negotiate/UserRequest.cc

index 7699dc076740826136f6a5a015dc47477a56b8e8..8c44f21146f2395f024ac9c72a91afd0cf032abc 100644 (file)
@@ -9,9 +9,11 @@
 #include "squid.h"
 #include "AccessLogEntry.h"
 #include "auth/negotiate/Config.h"
+#include "auth/negotiate/User.h"
 #include "auth/negotiate/UserRequest.h"
 #include "auth/State.h"
 #include "auth/User.h"
+#include "auth/UserNameCache.h"
 #include "client_side.h"
 #include "fatal.h"
 #include "format/Format.h"
@@ -331,29 +333,15 @@ Auth::Negotiate::UserRequest::HandleReply(void *data, const Helper::Reply &reply
 
         /* connection is authenticated */
         debugs(29, 4, HERE << "authenticated user " << auth_user_request->user()->username());
-#if !NEWCACHE
-        /* see if this is an existing user */
-        AuthUserHashPointer *usernamehash = static_cast<AuthUserHashPointer *>(hash_lookup(proxy_auth_username_cache, auth_user_request->user()->userKey()));
-        Auth::User::Pointer local_auth_user = lm_request->user();
-        while (usernamehash && (usernamehash->user()->auth_type != Auth::AUTH_NEGOTIATE ||
-                                strcmp(usernamehash->user()->userKey(), auth_user_request->user()->userKey()) != 0))
-            usernamehash = static_cast<AuthUserHashPointer *>(usernamehash->next);
-        if (usernamehash) {
-            /* we can't seamlessly recheck the username due to the
-             * challenge-response nature of the protocol.
-             * Just free the temporary auth_user after merging as
-             * much of it new state into the existing one as possible */
-            usernamehash->user()->absorb(local_auth_user);
-            /* from here on we are working with the original cached credentials. */
-            local_auth_user = usernamehash->user();
-            auth_user_request->user(local_auth_user);
-        } else {
-            /* store user in hash's */
+        auto local_auth_user = lm_request->user();
+        auto cached_user = Auth::Negotiate::User::Cache()->lookup(auth_user_request->user()->SBUserKey());
+        if (!cached_user) {
             local_auth_user->addToNameCache();
+        } else {
+            cached_user->absorb(local_auth_user);
+            local_auth_user = cached_user;
+            auth_user_request->user(local_auth_user);
         }
-#else
-
-#endif
         /* set these to now because this is either a new login from an
          * existing user or a new user */
         local_auth_user->expiretime = current_time.tv_sec;