]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/Gadgets.cc
014f052b8bec39292bfff7086d6745d26a0b9c0a
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 "http/Stream.h"
32 #include "HttpReply.h"
33 #include "HttpRequest.h"
35 /**** PUBLIC FUNCTIONS (ALL GENERIC!) ****/
38 authenticateActiveSchemeCount(void)
42 for (const auto *scheme
: Auth::TheConfig
.schemes
) {
43 if (scheme
->configured())
47 debugs(29, 9, HERE
<< rv
<< " active.");
53 authenticateSchemeCount(void)
55 int rv
= Auth::Scheme::GetSchemes().size();
57 debugs(29, 9, HERE
<< rv
<< " active.");
63 authenticateRegisterWithCacheManager(Auth::ConfigVector
* config
)
65 for (auto *scheme
: *config
)
66 scheme
->registerWithCacheManager();
70 authenticateInit(Auth::ConfigVector
* config
)
72 /* If we do not have any auth config state to create stop now. */
76 for (auto *scheme
: *config
) {
77 if (scheme
->configured())
81 authenticateRegisterWithCacheManager(config
);
85 authenticateRotate(void)
87 for (auto *scheme
: Auth::TheConfig
.schemes
) {
88 if (scheme
->configured())
89 scheme
->rotateHelpers();
94 authenticateReset(void)
96 debugs(29, 2, "Reset authentication State.");
98 // username cache is cleared via Runner registry
100 /* schedule shutdown of the helpers */
101 authenticateRotate();
103 /* free current global config details too. */
104 Auth::TheConfig
.schemes
.clear();
107 std::vector
<Auth::User::Pointer
>
108 authenticateCachedUsersList()
110 auto aucp_compare
= [=](const Auth::User::Pointer lhs
, const Auth::User::Pointer rhs
) {
111 return lhs
->userKey() < rhs
->userKey();
113 std::vector
<Auth::User::Pointer
> v1
, v2
, rv
, u1
, u2
;
114 #if HAVE_AUTH_MODULE_BASIC
115 if (Auth::SchemeConfig::Find("basic"))
116 u1
= Auth::Basic::User::Cache()->sortedUsersList();
118 #if HAVE_AUTH_MODULE_DIGEST
119 if (Auth::SchemeConfig::Find("digest"))
120 u2
= Auth::Digest::User::Cache()->sortedUsersList();
122 if (u1
.size() > 0 || u2
.size() > 0) {
123 v1
.reserve(u1
.size()+u2
.size());
124 std::merge(u1
.begin(), u1
.end(),u2
.begin(), u2
.end(),
125 std::back_inserter(v1
), aucp_compare
);
129 #if HAVE_AUTH_MODULE_NEGOTIATE
130 if (Auth::SchemeConfig::Find("negotiate"))
131 u1
= Auth::Negotiate::User::Cache()->sortedUsersList();
133 #if HAVE_AUTH_MODULE_NTLM
134 if (Auth::SchemeConfig::Find("ntlm"))
135 u2
= Auth::Ntlm::User::Cache()->sortedUsersList();
137 if (u1
.size() > 0 || u2
.size() > 0) {
138 v2
.reserve(u1
.size()+u2
.size());
139 std::merge(u1
.begin(), u1
.end(),u2
.begin(), u2
.end(),
140 std::back_inserter(v2
), aucp_compare
);
142 rv
.reserve(v1
.size()+v2
.size());
143 std::merge(v1
.begin(), v1
.end(),v2
.begin(), v2
.end(),
144 std::back_inserter(rv
), aucp_compare
);