28Auth::Negotiate::UserRequest::UserRequest() :
35Auth::Negotiate::UserRequest::~UserRequest()
50Auth::Negotiate::UserRequest::connLastHeader()
56Auth::Negotiate::UserRequest::credentialsStr()
61 printResult = snprintf(buf,
sizeof(buf),
"YR %s\n", client_blob);
63 printResult = snprintf(buf,
sizeof(buf),
"KK %s\n", client_blob);
67 if (printResult < 0) {
68 debugs(29, 2,
"Can not build negotiate authentication credentials.");
70 }
else if (printResult >= (
int)
sizeof(buf))
71 debugs(29, 2,
"Negotiate authentication credentials truncated.");
77Auth::Negotiate::UserRequest::module_direction()
81 if (waiting || client_blob)
87 switch (user()->credentials()) {
100 debugs(29,
DBG_IMPORTANT,
"WARNING: Negotiate Authentication in unexpected state: " << user()->credentials());
113 assert(user() !=
nullptr);
122 debugs(29, 8,
"credentials state is '" << user()->credentials() <<
"'");
124 const char *keyExtras = helperRequestKeyExtras(request, al);
128 printResult = snprintf(buf,
sizeof(buf),
"YR %s %s\n", client_blob, keyExtras);
130 printResult = snprintf(buf,
sizeof(buf),
"YR %s\n", client_blob);
133 printResult = snprintf(buf,
sizeof(buf),
"KK %s %s\n", client_blob, keyExtras);
135 printResult = snprintf(buf,
sizeof(buf),
"KK %s\n", client_blob);
138 if (printResult < 0 || printResult >= (
int)
sizeof(buf)) {
140 debugs(29,
DBG_CRITICAL,
"ERROR: Can not build negotiate authentication helper request");
142 debugs(29,
DBG_CRITICAL,
"ERROR: Negotiate authentication helper request too big for the " <<
sizeof(buf) <<
"-byte buffer");
160Auth::Negotiate::UserRequest::releaseAuthServer()
163 debugs(29, 6, reservationId);
165 reservationId.clear();
167 debugs(29, 6,
"No Negotiate auth server to release.");
178 debugs(29,
DBG_IMPORTANT,
"WARNING: Negotiate Authentication attempt to perform authentication without a connection!");
188 debugs(29, 2,
"need to challenge client '" << server_blob <<
"'!");
196 const char *blob = proxy_auth;
209 switch (user()->credentials()) {
213 debugs(29, 9,
"auth state negotiate none. Received blob: '" << proxy_auth <<
"'");
218 conn->
setAuth(
this,
"new Negotiate handshake request");
239 fatal(
"Auth::Negotiate::UserRequest::authenticate: unexpected auth state DONE! Report a bug to the squid developers.\n");
244 debugs(29, 9,
"auth state negotiate failed. " << proxy_auth);
250Auth::Negotiate::UserRequest::HandleReply(
void *data,
const Helper::Reply &reply)
263 assert(auth_user_request !=
nullptr);
268 auth_user_request->
user()->notes.replaceOrAddOrAppend(&reply.
notes, appendables);
270 auth_user_request->
user()->notes.remove(
"token");
272 Auth::Negotiate::UserRequest *lm_request =
dynamic_cast<Auth::Negotiate::UserRequest *
>(auth_user_request.
getRaw());
273 assert(lm_request !=
nullptr);
274 assert(lm_request->waiting);
276 lm_request->waiting = 0;
282 if (!lm_request->reservationId)
292 if (lm_request->request)
293 lm_request->request->flags.mustKeepalive =
true;
295 if (lm_request->request && lm_request->request->flags.proxyKeepalive) {
297 lm_request->server_blob =
xstrdup(tokenNote);
300 debugs(29, 4,
"Need to challenge the client with a server token: '" << tokenNote <<
"'");
303 auth_user_request->
setDenyMessage(
"Negotiate authentication requires a persistent connection");
310 if (userNote ==
nullptr || tokenNote ==
nullptr) {
313 fatalf(
"authenticateNegotiateHandleReply: *** Unsupported helper response ***, '%s'\n", reply.
other().
content());
318 auth_user_request->
user()->username(userNote);
321 lm_request->server_blob =
xstrdup(tokenNote);
322 lm_request->releaseAuthServer();
325 debugs(29, 4,
"authenticated user " << auth_user_request->
user()->username());
326 auto local_auth_user = lm_request->user();
327 auto cached_user = Auth::Negotiate::User::Cache()->lookup(auth_user_request->
user()->userKey());
329 local_auth_user->addToNameCache();
335 cached_user->absorb(local_auth_user);
337 local_auth_user = cached_user;
338 auth_user_request->
user(local_auth_user);
344 debugs(29, 4,
"Successfully validated user via Negotiate. Username '" << auth_user_request->
user()->username() <<
"'");
354 lm_request->server_blob =
xstrdup(tokenNote);
355 lm_request->releaseAuthServer();
356 debugs(29, 4,
"Failed validating user via Negotiate. Result: " << reply);
376 lm_request->releaseAuthServer();
377 debugs(29,
DBG_IMPORTANT,
"ERROR: Negotiate Authentication validating user. Result: " << reply);
381 if (lm_request->request) {
383 lm_request->request =
nullptr;
Helper::StatefulClientPointer negotiateauthenticators
int cbdataReferenceValid(const void *p)
static SchemeConfig * Find(const char *proxy_auth)
UserRequest::Pointer auth_user_request
void setDenyMessage(char const *)
void denyMessageFromHelper(char const *proto, const Helper::Reply &reply)
Sets the reason of 'authentication denied' helper response.
virtual User::Pointer user()
void setAuth(const Auth::UserRequest::Pointer &aur, const char *cause)
const Auth::UserRequest::Pointer & getAuth() const
Helper::ResultCode result
The helper response 'result' field.
const MemBuf & other() const
Helper::ReservationId reservationId
The stateful replies should include the reservation ID.
char * content()
start of the added data
std::vector< SBuf > Names
const char * findFirst(const char *noteKey) const
void cancelReservation(const Helper::ReservationId reservation)
undo reserveServer(), clear the reservation and kick the queue
#define debugs(SECTION, LEVEL, CONTENT)
void fatal(const char *message)
void fatalf(const char *fmt,...)
void helperStatefulSubmit(const statefulhelper::Pointer &hlp, const char *buf, HLPCB *callback, void *data, const Helper::ReservationId &reservation)
void HTTPMSGUNLOCK(M *&a)
void HTTPMSGLOCK(Http::Message *a)
@ CRED_ERROR
ERROR in the auth module. Cannot determine the state of this request.
@ CRED_CHALLENGE
Client needs to be challenged. secure token.
@ CRED_LOOKUP
Credentials need to be validated with the backend helper.
@ CRED_VALID
Credentials are valid and a up to date. The OK/Failed state is accurate.
#define MAX_AUTHTOKEN_LEN
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format