]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/basic/User.cc
2 * Copyright (C) 1996-2014 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.
10 #include "auth/basic/auth_basic.h"
11 #include "auth/basic/User.h"
13 #include "SquidConfig.h"
14 #include "SquidTime.h"
16 Auth::Basic::User::User(Auth::Config
*aConfig
, const char *aRequestRealm
) :
17 Auth::User(aConfig
, aRequestRealm
),
23 Auth::Basic::User::~User()
29 Auth::Basic::User::ttl() const
31 if (credentials() != Auth::Ok
&& credentials() != Auth::Pending
)
32 return -1; // TTL is obsolete NOW.
34 int32_t basic_ttl
= expiretime
- squid_curtime
+ static_cast<Auth::Basic::Config
*>(config
)->credentialsTTL
;
35 int32_t global_ttl
= static_cast<int32_t>(expiretime
- squid_curtime
+ ::Config
.authenticateTTL
);
37 return min(basic_ttl
, global_ttl
);
41 Auth::Basic::User::authenticated() const
43 if ((credentials() == Auth::Ok
) && (expiretime
+ static_cast<Auth::Basic::Config
*>(config
)->credentialsTTL
> squid_curtime
))
46 debugs(29, 4, "User not authenticated or credentials need rechecking.");
52 Auth::Basic::User::valid() const
54 if (username() == NULL
)
62 Auth::Basic::User::updateCached(Auth::Basic::User
*from
)
64 debugs(29, 9, HERE
<< "Found user '" << from
->username() << "' already in the user cache as '" << this << "'");
66 assert(strcmp(from
->username(), username()) == 0);
68 if (strcmp(from
->passwd
, passwd
)) {
69 debugs(29, 4, HERE
<< "new password found. Updating in user master record and resetting auth state to unchecked");
70 credentials(Auth::Unchecked
);
72 passwd
= from
->passwd
;
76 if (credentials() == Auth::Failed
) {
77 debugs(29, 4, HERE
<< "last attempt to authenticate this user failed, resetting auth state to unchecked");
78 credentials(Auth::Unchecked
);