2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 29 Authenticator */
11 /* The functions in this file handle authentication.
12 * They DO NOT perform access control or auditing.
13 * See acl.c for access control and client_side.c for auditing */
17 #include "acl/FilledChecklist.h"
18 #include "auth/AclProxyAuth.h"
19 #include "auth/Config.h"
20 #include "auth/Gadgets.h"
21 #include "auth/Scheme.h"
22 #include "auth/User.h"
23 #include "auth/UserRequest.h"
24 #include "client_side.h"
26 #include "HttpReply.h"
27 #include "HttpRequest.h"
29 /**** PUBLIC FUNCTIONS (ALL GENERIC!) ****/
32 authenticateActiveSchemeCount(void)
36 for (Auth::ConfigVector::iterator i
= Auth::TheConfig
.begin(); i
!= Auth::TheConfig
.end(); ++i
)
37 if ((*i
)->configured())
40 debugs(29, 9, HERE
<< rv
<< " active.");
46 authenticateSchemeCount(void)
48 int rv
= Auth::Scheme::GetSchemes().size();
50 debugs(29, 9, HERE
<< rv
<< " active.");
56 authenticateRegisterWithCacheManager(Auth::ConfigVector
* config
)
58 for (Auth::ConfigVector::iterator i
= config
->begin(); i
!= config
->end(); ++i
) {
59 Auth::Config
*scheme
= *i
;
60 scheme
->registerWithCacheManager();
65 authenticateInit(Auth::ConfigVector
* config
)
67 /* Do this first to clear memory and remove dead state on a reconfigure */
68 if (proxy_auth_username_cache
)
69 Auth::User::CachedACLsReset();
71 /* If we do not have any auth config state to create stop now. */
75 for (Auth::ConfigVector::iterator i
= config
->begin(); i
!= config
->end(); ++i
) {
76 Auth::Config
*schemeCfg
= *i
;
78 if (schemeCfg
->configured())
79 schemeCfg
->init(schemeCfg
);
82 if (!proxy_auth_username_cache
)
83 Auth::User::cacheInit();
85 authenticateRegisterWithCacheManager(config
);
89 authenticateRotate(void)
91 for (Auth::ConfigVector::iterator i
= Auth::TheConfig
.begin(); i
!= Auth::TheConfig
.end(); ++i
)
92 if ((*i
)->configured())
93 (*i
)->rotateHelpers();
97 authenticateReset(void)
99 debugs(29, 2, HERE
<< "Reset authentication State.");
101 /* free all username cache entries */
102 hash_first(proxy_auth_username_cache
);
103 AuthUserHashPointer
*usernamehash
;
104 while ((usernamehash
= ((AuthUserHashPointer
*) hash_next(proxy_auth_username_cache
)))) {
105 debugs(29, 5, HERE
<< "Clearing entry for user: " << usernamehash
->user()->username());
106 hash_remove_link(proxy_auth_username_cache
, (hash_link
*)usernamehash
);
110 /* schedule shutdown of the helpers */
111 authenticateRotate();
113 /* free current global config details too. */
114 Auth::TheConfig
.clear();
117 AuthUserHashPointer::AuthUserHashPointer(Auth::User::Pointer anAuth_user
):
118 auth_user(anAuth_user
)
120 key
= (void *)anAuth_user
->userKey();
122 hash_join(proxy_auth_username_cache
, (hash_link
*) this);
126 AuthUserHashPointer::user() const