]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/Gadgets.cc
2 * Copyright (C) 1996-2016 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/basic/User.h"
20 #include "auth/Config.h"
21 #include "auth/CredentialsCache.h"
22 #include "auth/digest/User.h"
23 #include "auth/Gadgets.h"
24 #include "auth/negotiate/User.h"
25 #include "auth/ntlm/User.h"
26 #include "auth/Scheme.h"
27 #include "auth/User.h"
28 #include "auth/UserRequest.h"
29 #include "client_side.h"
31 #include "HttpReply.h"
32 #include "HttpRequest.h"
34 /**** PUBLIC FUNCTIONS (ALL GENERIC!) ****/
37 authenticateActiveSchemeCount(void)
41 for (Auth::ConfigVector::iterator i
= Auth::TheConfig
.begin(); i
!= Auth::TheConfig
.end(); ++i
)
42 if ((*i
)->configured())
45 debugs(29, 9, HERE
<< rv
<< " active.");
51 authenticateSchemeCount(void)
53 int rv
= Auth::Scheme::GetSchemes().size();
55 debugs(29, 9, HERE
<< rv
<< " active.");
61 authenticateRegisterWithCacheManager(Auth::ConfigVector
* config
)
63 for (Auth::ConfigVector::iterator i
= config
->begin(); i
!= config
->end(); ++i
) {
64 Auth::Config
*scheme
= *i
;
65 scheme
->registerWithCacheManager();
70 authenticateInit(Auth::ConfigVector
* config
)
72 /* If we do not have any auth config state to create stop now. */
76 for (Auth::ConfigVector::iterator i
= config
->begin(); i
!= config
->end(); ++i
) {
77 Auth::Config
*schemeCfg
= *i
;
79 if (schemeCfg
->configured())
80 schemeCfg
->init(schemeCfg
);
83 authenticateRegisterWithCacheManager(config
);
87 authenticateRotate(void)
89 for (Auth::ConfigVector::iterator i
= Auth::TheConfig
.begin(); i
!= Auth::TheConfig
.end(); ++i
)
90 if ((*i
)->configured())
91 (*i
)->rotateHelpers();
95 authenticateReset(void)
97 debugs(29, 2, "Reset authentication State.");
99 // username cache is cleared via Runner registry
101 /* schedule shutdown of the helpers */
102 authenticateRotate();
104 /* free current global config details too. */
105 Auth::TheConfig
.clear();
108 std::vector
<Auth::User::Pointer
>
109 authenticateCachedUsersList()
111 auto aucp_compare
= [=](const Auth::User::Pointer lhs
, const Auth::User::Pointer rhs
) {
112 return lhs
->userKey() < rhs
->userKey();
114 std::vector
<Auth::User::Pointer
> v1
, v2
, rv
, u1
, u2
;
115 #if HAVE_AUTH_MODULE_BASIC
116 if (Auth::Config::Find("basic") != nullptr)
117 u1
= Auth::Basic::User::Cache()->sortedUsersList();
119 #if HAVE_AUTH_MODULE_DIGEST
120 if (Auth::Config::Find("digest") != nullptr)
121 u2
= Auth::Digest::User::Cache()->sortedUsersList();
123 if (u1
.size() > 0 || u2
.size() > 0) {
124 v1
.reserve(u1
.size()+u2
.size());
125 std::merge(u1
.begin(), u1
.end(),u2
.begin(), u2
.end(),
126 std::back_inserter(v1
), aucp_compare
);
130 #if HAVE_AUTH_MODULE_NEGOTIATE
131 if (Auth::Config::Find("negotiate") != nullptr)
132 u1
= Auth::Negotiate::User::Cache()->sortedUsersList();
134 #if HAVE_AUTH_MODULE_NTLM
135 if (Auth::Config::Find("ntlm") != nullptr)
136 u2
= Auth::Ntlm::User::Cache()->sortedUsersList();
138 if (u1
.size() > 0 || u2
.size() > 0) {
139 v2
.reserve(u1
.size()+u2
.size());
140 std::merge(u1
.begin(), u1
.end(),u2
.begin(), u2
.end(),
141 std::back_inserter(v2
), aucp_compare
);
143 rv
.reserve(v1
.size()+v2
.size());
144 std::merge(v1
.begin(), v1
.end(),v2
.begin(), v2
.end(),
145 std::back_inserter(rv
), aucp_compare
);