]> git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/digest/auth_digest.cc
SourceLayout: acl/, take 1
[thirdparty/squid.git] / src / auth / digest / auth_digest.cc
1 /*
2 * $Id$
3 *
4 * DEBUG: section 29 Authenticator
5 * AUTHOR: Robert Collins
6 *
7 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
8 * ----------------------------------------------------------
9 *
10 * Squid is the result of efforts by numerous individuals from the
11 * Internet community. Development is led by Duane Wessels of the
12 * National Laboratory for Applied Network Research and funded by the
13 * National Science Foundation. Squid is Copyrighted (C) 1998 by
14 * the Regents of the University of California. Please see the
15 * COPYRIGHT file for full details. Squid incorporates software
16 * developed and/or copyrighted by other sources. Please see the
17 * CREDITS file for full details.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 *
33 */
34
35 /* The functions in this file handle authentication.
36 * They DO NOT perform access control or auditing.
37 * See acl.c for access control and client_side.c for auditing */
38
39
40 #include "squid.h"
41 #include "rfc2617.h"
42 #include "auth_digest.h"
43 #include "auth/Gadgets.h"
44 #include "event.h"
45 #include "CacheManager.h"
46 #include "Store.h"
47 #include "HttpRequest.h"
48 #include "HttpReply.h"
49 #include "wordlist.h"
50 #include "SquidTime.h"
51 /* TODO don't include this */
52 #include "digestScheme.h"
53
54 /* Digest Scheme */
55
56 static HLPCB authenticateDigestHandleReply;
57 static AUTHSSTATS authenticateDigestStats;
58
59 static helper *digestauthenticators = NULL;
60
61 static hash_table *digest_nonce_cache;
62
63 static AuthDigestConfig digestConfig;
64
65 static int authdigest_initialised = 0;
66 static MemAllocator *digest_nonce_pool = NULL;
67
68 CBDATA_TYPE(DigestAuthenticateStateData);
69
70 /*
71 *
72 * Nonce Functions
73 *
74 */
75
76 static void authenticateDigestNonceCacheCleanup(void *data);
77 static digest_nonce_h *authenticateDigestNonceFindNonce(const char *nonceb64);
78 static digest_nonce_h *authenticateDigestNonceNew(void);
79 static void authenticateDigestNonceDelete(digest_nonce_h * nonce);
80 static void authenticateDigestNonceSetup(void);
81 static void authenticateDigestNonceShutdown(void);
82 static void authenticateDigestNonceReconfigure(void);
83 static const char *authenticateDigestNonceNonceb64(digest_nonce_h * nonce);
84 static int authDigestNonceIsValid(digest_nonce_h * nonce, char nc[9]);
85 static int authDigestNonceIsStale(digest_nonce_h * nonce);
86 static void authDigestNonceEncode(digest_nonce_h * nonce);
87 static int authDigestNonceLastRequest(digest_nonce_h * nonce);
88 static void authDigestNonceLink(digest_nonce_h * nonce);
89 static void authDigestNonceUnlink(digest_nonce_h * nonce);
90 #if NOT_USED
91 static int authDigestNonceLinks(digest_nonce_h * nonce);
92 #endif
93 static void authDigestNonceUserUnlink(digest_nonce_h * nonce);
94 static void authDigestNoncePurge(digest_nonce_h * nonce);
95
96 static void
97 authDigestNonceEncode(digest_nonce_h * nonce)
98 {
99 if (!nonce)
100 return;
101
102 if (nonce->key)
103 xfree(nonce->key);
104
105 nonce->key = xstrdup(base64_encode_bin((char *) &(nonce->noncedata), sizeof(digest_nonce_data)));
106 }
107
108 static digest_nonce_h *
109 authenticateDigestNonceNew(void)
110 {
111 digest_nonce_h *newnonce = static_cast < digest_nonce_h * >(digest_nonce_pool->alloc());
112 digest_nonce_h *temp;
113
114 /* NONCE CREATION - NOTES AND REASONING. RBC 20010108
115 * === EXCERPT FROM RFC 2617 ===
116 * The contents of the nonce are implementation dependent. The quality
117 * of the implementation depends on a good choice. A nonce might, for
118 * example, be constructed as the base 64 encoding of
119 *
120 * time-stamp H(time-stamp ":" ETag ":" private-key)
121 *
122 * where time-stamp is a server-generated time or other non-repeating
123 * value, ETag is the value of the HTTP ETag header associated with
124 * the requested entity, and private-key is data known only to the
125 * server. With a nonce of this form a server would recalculate the
126 * hash portion after receiving the client authentication header and
127 * reject the request if it did not match the nonce from that header
128 * or if the time-stamp value is not recent enough. In this way the
129 * server can limit the time of the nonce's validity. The inclusion of
130 * the ETag prevents a replay request for an updated version of the
131 * resource. (Note: including the IP address of the client in the
132 * nonce would appear to offer the server the ability to limit the
133 * reuse of the nonce to the same client that originally got it.
134 * However, that would break proxy farms, where requests from a single
135 * user often go through different proxies in the farm. Also, IP
136 * address spoofing is not that hard.)
137 * ====
138 *
139 * Now for my reasoning:
140 * We will not accept a unrecognised nonce->we have all recognisable
141 * nonces stored. If we send out unique base64 encodings we guarantee
142 * that a given nonce applies to only one user (barring attacks or
143 * really bad timing with expiry and creation). Using a random
144 * component in the nonce allows us to loop to find a unique nonce.
145 * We use H(nonce_data) so the nonce is meaningless to the reciever.
146 * So our nonce looks like base64(H(timestamp,pointertohash,randomdata))
147 * And even if our randomness is not very random (probably due to
148 * bad coding on my part) we don't really care - the timestamp and
149 * memory pointer also guarantee local uniqueness in the input to the hash
150 * function.
151 */
152
153 /* create a new nonce */
154 newnonce->nc = 0;
155 newnonce->flags.valid = 1;
156 newnonce->noncedata.self = newnonce;
157 newnonce->noncedata.creationtime = current_time.tv_sec;
158 newnonce->noncedata.randomdata = squid_random();
159
160 authDigestNonceEncode(newnonce);
161 /*
162 * loop until we get a unique nonce. The nonce creation must
163 * have a random factor
164 */
165
166 while ((temp = authenticateDigestNonceFindNonce((char const *) (newnonce->key)))) {
167 /* create a new nonce */
168 newnonce->noncedata.randomdata = squid_random();
169 authDigestNonceEncode(newnonce);
170 }
171
172 hash_join(digest_nonce_cache, newnonce);
173 /* the cache's link */
174 authDigestNonceLink(newnonce);
175 newnonce->flags.incache = 1;
176 debugs(29, 5, "authenticateDigestNonceNew: created nonce " << newnonce << " at " << newnonce->noncedata.creationtime);
177 return newnonce;
178 }
179
180 static void
181 authenticateDigestNonceDelete(digest_nonce_h * nonce)
182 {
183 if (nonce) {
184 assert(nonce->references == 0);
185 #if UNREACHABLECODE
186
187 if (nonce->flags.incache)
188 hash_remove_link(digest_nonce_cache, nonce);
189
190 #endif
191
192 assert(nonce->flags.incache == 0);
193
194 safe_free(nonce->key);
195
196 digest_nonce_pool->free(nonce);
197 }
198 }
199
200 static void
201 authenticateDigestNonceSetup(void)
202 {
203 if (!digest_nonce_pool)
204 digest_nonce_pool = memPoolCreate("Digest Scheme nonce's", sizeof(digest_nonce_h));
205
206 if (!digest_nonce_cache) {
207 digest_nonce_cache = hash_create((HASHCMP *) strcmp, 7921, hash_string);
208 assert(digest_nonce_cache);
209 eventAdd("Digest none cache maintenance", authenticateDigestNonceCacheCleanup, NULL, digestConfig.nonceGCInterval, 1);
210 }
211 }
212
213 static void
214 authenticateDigestNonceShutdown(void)
215 {
216 /*
217 * We empty the cache of any nonces left in there.
218 */
219 digest_nonce_h *nonce;
220
221 if (digest_nonce_cache) {
222 debugs(29, 2, "authenticateDigestNonceShutdown: Shutting down nonce cache ");
223 hash_first(digest_nonce_cache);
224
225 while ((nonce = ((digest_nonce_h *) hash_next(digest_nonce_cache)))) {
226 assert(nonce->flags.incache);
227 authDigestNoncePurge(nonce);
228 }
229 }
230
231 #if DEBUGSHUTDOWN
232 if (digest_nonce_pool) {
233 delete digest_nonce_pool;
234 digest_nonce_pool = NULL;
235 }
236
237 #endif
238 debugs(29, 2, "authenticateDigestNonceShutdown: Nonce cache shutdown");
239 }
240
241 static void
242 authenticateDigestNonceReconfigure(void)
243 {}
244
245 static void
246 authenticateDigestNonceCacheCleanup(void *data)
247 {
248 /*
249 * We walk the hash by nonceb64 as that is the unique key we
250 * use. For big hash tables we could consider stepping through
251 * the cache, 100/200 entries at a time. Lets see how it flies
252 * first.
253 */
254 digest_nonce_h *nonce;
255 debugs(29, 3, "authenticateDigestNonceCacheCleanup: Cleaning the nonce cache now");
256 debugs(29, 3, "authenticateDigestNonceCacheCleanup: Current time: " << current_time.tv_sec);
257 hash_first(digest_nonce_cache);
258
259 while ((nonce = ((digest_nonce_h *) hash_next(digest_nonce_cache)))) {
260 debugs(29, 3, "authenticateDigestNonceCacheCleanup: nonce entry : " << nonce << " '" << (char *) nonce->key << "'");
261 debugs(29, 4, "authenticateDigestNonceCacheCleanup: Creation time: " << nonce->noncedata.creationtime);
262
263 if (authDigestNonceIsStale(nonce)) {
264 debugs(29, 4, "authenticateDigestNonceCacheCleanup: Removing nonce " << (char *) nonce->key << " from cache due to timeout.");
265 assert(nonce->flags.incache);
266 /* invalidate nonce so future requests fail */
267 nonce->flags.valid = 0;
268 /* if it is tied to a auth_user, remove the tie */
269 authDigestNonceUserUnlink(nonce);
270 authDigestNoncePurge(nonce);
271 }
272 }
273
274 debugs(29, 3, "authenticateDigestNonceCacheCleanup: Finished cleaning the nonce cache.");
275
276 if (digestConfig.active())
277 eventAdd("Digest none cache maintenance", authenticateDigestNonceCacheCleanup, NULL, digestConfig.nonceGCInterval, 1);
278 }
279
280 static void
281 authDigestNonceLink(digest_nonce_h * nonce)
282 {
283 assert(nonce != NULL);
284 nonce->references++;
285 debugs(29, 9, "authDigestNonceLink: nonce '" << nonce << "' now at '" << nonce->references << "'.");
286 }
287
288 #if NOT_USED
289 static int
290 authDigestNonceLinks(digest_nonce_h * nonce)
291 {
292 if (!nonce)
293 return -1;
294
295 return nonce->references;
296 }
297
298 #endif
299
300 static void
301 authDigestNonceUnlink(digest_nonce_h * nonce)
302 {
303 assert(nonce != NULL);
304
305 if (nonce->references > 0) {
306 nonce->references--;
307 } else {
308 debugs(29, 1, "authDigestNonceUnlink; Attempt to lower nonce " << nonce << " refcount below 0!");
309 }
310
311 debugs(29, 9, "authDigestNonceUnlink: nonce '" << nonce << "' now at '" << nonce->references << "'.");
312
313 if (nonce->references == 0)
314 authenticateDigestNonceDelete(nonce);
315 }
316
317 static const char *
318 authenticateDigestNonceNonceb64(digest_nonce_h * nonce)
319 {
320 if (!nonce)
321 return NULL;
322
323 return (char const *) nonce->key;
324 }
325
326 static digest_nonce_h *
327 authenticateDigestNonceFindNonce(const char *nonceb64)
328 {
329 digest_nonce_h *nonce = NULL;
330
331 if (nonceb64 == NULL)
332 return NULL;
333
334 debugs(29, 9, "authDigestNonceFindNonce:looking for nonceb64 '" << nonceb64 << "' in the nonce cache.");
335
336 nonce = static_cast < digest_nonce_h * >(hash_lookup(digest_nonce_cache, nonceb64));
337
338 if ((nonce == NULL) || (strcmp(authenticateDigestNonceNonceb64(nonce), nonceb64)))
339 return NULL;
340
341 debugs(29, 9, "authDigestNonceFindNonce: Found nonce '" << nonce << "'");
342
343 return nonce;
344 }
345
346 static int
347 authDigestNonceIsValid(digest_nonce_h * nonce, char nc[9])
348 {
349 unsigned long intnc;
350 /* do we have a nonce ? */
351
352 if (!nonce)
353 return 0;
354
355 intnc = strtol(nc, NULL, 16);
356
357 /* has it already been invalidated ? */
358 if (!nonce->flags.valid) {
359 debugs(29, 4, "authDigestNonceIsValid: Nonce already invalidated");
360 return 0;
361 }
362
363 /* is the nonce-count ok ? */
364 if (!digestConfig.CheckNonceCount) {
365 nonce->nc++;
366 return -1; /* forced OK by configuration */
367 }
368
369 if ((digestConfig.NonceStrictness && intnc != nonce->nc + 1) ||
370 intnc < nonce->nc + 1) {
371 debugs(29, 4, "authDigestNonceIsValid: Nonce count doesn't match");
372 nonce->flags.valid = 0;
373 return 0;
374 }
375
376 /* seems ok */
377 /* increment the nonce count - we've already checked that intnc is a
378 * valid representation for us, so we don't need the test here.
379 */
380 nonce->nc = intnc;
381
382 return -1;
383 }
384
385 static int
386 authDigestNonceIsStale(digest_nonce_h * nonce)
387 {
388 /* do we have a nonce ? */
389
390 if (!nonce)
391 return -1;
392
393 /* has it's max duration expired? */
394 if (nonce->noncedata.creationtime + digestConfig.noncemaxduration < current_time.tv_sec) {
395 debugs(29, 4, "authDigestNonceIsStale: Nonce is too old. " <<
396 nonce->noncedata.creationtime << " " <<
397 digestConfig.noncemaxduration << " " <<
398 current_time.tv_sec);
399
400 nonce->flags.valid = 0;
401 return -1;
402 }
403
404 if (nonce->nc > 99999998) {
405 debugs(29, 4, "authDigestNonceIsStale: Nonce count overflow");
406 nonce->flags.valid = 0;
407 return -1;
408 }
409
410 if (nonce->nc > digestConfig.noncemaxuses) {
411 debugs(29, 4, "authDigestNoncelastRequest: Nonce count over user limit");
412 nonce->flags.valid = 0;
413 return -1;
414 }
415
416 /* seems ok */
417 return 0;
418 }
419
420 /* return -1 if the digest will be stale on the next request */
421 static int
422 authDigestNonceLastRequest(digest_nonce_h * nonce)
423 {
424 if (!nonce)
425 return -1;
426
427 if (nonce->nc == 99999997) {
428 debugs(29, 4, "authDigestNoncelastRequest: Nonce count about to overflow");
429 return -1;
430 }
431
432 if (nonce->nc >= digestConfig.noncemaxuses - 1) {
433 debugs(29, 4, "authDigestNoncelastRequest: Nonce count about to hit user limit");
434 return -1;
435 }
436
437 /* and other tests are possible. */
438 return 0;
439 }
440
441 static void
442 authDigestNoncePurge(digest_nonce_h * nonce)
443 {
444 if (!nonce)
445 return;
446
447 if (!nonce->flags.incache)
448 return;
449
450 hash_remove_link(digest_nonce_cache, nonce);
451
452 nonce->flags.incache = 0;
453
454 /* the cache's link */
455 authDigestNonceUnlink(nonce);
456 }
457
458 /* USER related functions */
459 static AuthUser *
460 authDigestUserFindUsername(const char *username)
461 {
462 AuthUserHashPointer *usernamehash;
463 AuthUser *auth_user;
464 debugs(29, 9, HERE << "Looking for user '" << username << "'");
465
466 if (username && (usernamehash = static_cast < auth_user_hash_pointer * >(hash_lookup(proxy_auth_username_cache, username)))) {
467 while ((usernamehash->user()->auth_type != AUTH_DIGEST) &&
468 (usernamehash->next))
469 usernamehash = static_cast < auth_user_hash_pointer * >(usernamehash->next);
470
471 auth_user = NULL;
472
473 if (usernamehash->user()->auth_type == AUTH_DIGEST) {
474 auth_user = usernamehash->user();
475 }
476
477 return auth_user;
478 }
479
480 return NULL;
481 }
482
483 static void
484 authDigestUserShutdown(void)
485 {
486 /** \todo Future work: the auth framework could flush it's cache */
487 AuthUserHashPointer *usernamehash;
488 AuthUser *auth_user;
489 hash_first(proxy_auth_username_cache);
490
491 while ((usernamehash = ((auth_user_hash_pointer *) hash_next(proxy_auth_username_cache)))) {
492 auth_user = usernamehash->user();
493
494 if (strcmp(auth_user->config->type(), "digest") == 0)
495 auth_user->unlock();
496 }
497 }
498
499 /** delete the digest request structure. Does NOT delete related structures */
500 void
501 digestScheme::done()
502 {
503 /** \todo this should be a Config call. */
504
505 if (digestauthenticators)
506 helperShutdown(digestauthenticators);
507
508 authdigest_initialised = 0;
509
510 if (!shutting_down) {
511 authenticateDigestNonceReconfigure();
512 return;
513 }
514
515 if (digestauthenticators) {
516 helperFree(digestauthenticators);
517 digestauthenticators = NULL;
518 }
519
520 authDigestUserShutdown();
521 authenticateDigestNonceShutdown();
522 debugs(29, 2, "authenticateDigestDone: Digest authentication shut down.");
523 }
524
525 void
526 AuthDigestConfig::dump(StoreEntry * entry, const char *name, AuthConfig * scheme)
527 {
528 wordlist *list = authenticate;
529 debugs(29, 9, "authDigestCfgDump: Dumping configuration");
530 storeAppendPrintf(entry, "%s %s", name, "digest");
531
532 while (list != NULL) {
533 storeAppendPrintf(entry, " %s", list->key);
534 list = list->next;
535 }
536
537 storeAppendPrintf(entry, "\n%s %s realm %s\n%s %s children %d\n%s %s nonce_max_count %d\n%s %s nonce_max_duration %d seconds\n%s %s nonce_garbage_interval %d seconds\n",
538 name, "digest", digestAuthRealm,
539 name, "digest", authenticateChildren,
540 name, "digest", noncemaxuses,
541 name, "digest", (int) noncemaxduration,
542 name, "digest", (int) nonceGCInterval);
543 }
544
545 bool
546 AuthDigestConfig::active() const
547 {
548 return authdigest_initialised == 1;
549 }
550
551 bool
552 AuthDigestConfig::configured() const
553 {
554 if ((authenticate != NULL) &&
555 (authenticateChildren != 0) &&
556 (digestAuthRealm != NULL) && (noncemaxduration > -1))
557 return true;
558
559 return false;
560 }
561
562 int
563 AuthDigestUserRequest::authenticated() const
564 {
565 if (credentials() == Ok)
566 return 1;
567
568 return 0;
569 }
570
571 /** log a digest user in
572 */
573 void
574 AuthDigestUserRequest::authenticate(HttpRequest * request, ConnStateData * conn, http_hdr_type type)
575 {
576 AuthUser *auth_user;
577 AuthDigestUserRequest *digest_request;
578 digest_user_h *digest_user;
579
580 HASHHEX SESSIONKEY;
581 HASHHEX HA2 = "";
582 HASHHEX Response;
583
584 assert(authUser() != NULL);
585 auth_user = authUser();
586
587 digest_user = dynamic_cast < digest_user_h * >(auth_user);
588
589 assert(digest_user != NULL);
590
591 /* if the check has corrupted the user, just return */
592
593 if (credentials() == Failed) {
594 return;
595 }
596
597 digest_request = this;
598
599 /* do we have the HA1 */
600
601 if (!digest_user->HA1created) {
602 credentials(Pending);
603 return;
604 }
605
606 if (digest_request->nonce == NULL) {
607 /* this isn't a nonce we issued */
608 credentials(Failed);
609 return;
610 }
611
612 DigestCalcHA1(digest_request->algorithm, NULL, NULL, NULL,
613 authenticateDigestNonceNonceb64(digest_request->nonce),
614 digest_request->cnonce,
615 digest_user->HA1, SESSIONKEY);
616 DigestCalcResponse(SESSIONKEY, authenticateDigestNonceNonceb64(digest_request->nonce),
617 digest_request->nc, digest_request->cnonce, digest_request->qop,
618 RequestMethodStr(request->method), digest_request->uri, HA2, Response);
619
620 debugs(29, 9, "\nResponse = '" << digest_request->response << "'\nsquid is = '" << Response << "'");
621
622 if (strcasecmp(digest_request->response, Response) != 0) {
623 if (!digest_request->flags.helper_queried) {
624 /* Query the helper in case the password has changed */
625 digest_request->flags.helper_queried = 1;
626 digest_request->credentials_ok = Pending;
627 return;
628 }
629
630 if (digestConfig.PostWorkaround && request->method != METHOD_GET) {
631 /* Ugly workaround for certain very broken browsers using the
632 * wrong method to calculate the request-digest on POST request.
633 * This should be deleted once Digest authentication becomes more
634 * widespread and such broken browsers no longer are commonly
635 * used.
636 */
637 DigestCalcResponse(SESSIONKEY, authenticateDigestNonceNonceb64(digest_request->nonce),
638 digest_request->nc, digest_request->cnonce, digest_request->qop,
639 RequestMethodStr(METHOD_GET), digest_request->uri, HA2, Response);
640
641 if (strcasecmp(digest_request->response, Response)) {
642 credentials(Failed);
643 digest_request->setDenyMessage("Incorrect password");
644 return;
645 } else {
646 const char *useragent = request->header.getStr(HDR_USER_AGENT);
647
648 static IpAddress last_broken_addr;
649 static int seen_broken_client = 0;
650
651 if (!seen_broken_client) {
652 last_broken_addr.SetNoAddr();
653 seen_broken_client = 1;
654 }
655
656 if (last_broken_addr != request->client_addr) {
657 debugs(29, 1, "\nDigest POST bug detected from " <<
658 request->client_addr << " using '" <<
659 (useragent ? useragent : "-") <<
660 "'. Please upgrade browser. See Bug #630 for details.");
661
662 last_broken_addr = request->client_addr;
663 }
664 }
665 } else {
666 credentials(Failed);
667 digest_request->flags.invalid_password = 1;
668 digest_request->setDenyMessage("Incorrect password");
669 return;
670 }
671
672 /* check for stale nonce */
673 if (!authDigestNonceIsValid(digest_request->nonce, digest_request->nc)) {
674 debugs(29, 3, "authenticateDigestAuthenticateuser: user '" << digest_user->username() << "' validated OK but nonce stale");
675 credentials(Failed);
676 digest_request->setDenyMessage("Stale nonce");
677 return;
678 }
679 }
680
681 credentials(Ok);
682
683 /* password was checked and did match */
684 debugs(29, 4, "authenticateDigestAuthenticateuser: user '" << digest_user->username() << "' validated OK");
685
686 /* auth_user is now linked, we reset these values
687 * after external auth occurs anyway */
688 auth_user->expiretime = current_time.tv_sec;
689 return;
690 }
691
692 int
693 AuthDigestUserRequest::module_direction()
694 {
695 switch (credentials()) {
696
697 case Unchecked:
698 return -1;
699
700 case Ok:
701
702 return 0;
703
704 case Pending:
705 return -1;
706
707 case Failed:
708
709 /* send new challenge */
710 return 1;
711 }
712
713 return -2;
714 }
715
716 /* add the [proxy]authorisation header */
717 void
718 AuthDigestUserRequest::addHeader(HttpReply * rep, int accel)
719 {
720 http_hdr_type type;
721
722 /* don't add to authentication error pages */
723
724 if ((!accel && rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED)
725 || (accel && rep->sline.status == HTTP_UNAUTHORIZED))
726 return;
727
728 type = accel ? HDR_AUTHENTICATION_INFO : HDR_PROXY_AUTHENTICATION_INFO;
729
730 #if WAITING_FOR_TE
731 /* test for http/1.1 transfer chunked encoding */
732 if (chunkedtest)
733 return;
734
735 #endif
736
737 if ((digestConfig.authenticate) && authDigestNonceLastRequest(nonce)) {
738 flags.authinfo_sent = 1;
739 debugs(29, 9, "authDigestAddHead: Sending type:" << type << " header: 'nextnonce=\"" << authenticateDigestNonceNonceb64(nonce) << "\"");
740 httpHeaderPutStrf(&rep->header, type, "nextnonce=\"%s\"", authenticateDigestNonceNonceb64(nonce));
741 }
742 }
743
744 #if WAITING_FOR_TE
745 /* add the [proxy]authorisation header */
746 void
747 AuthDigestUserRequest::addTrailer(HttpReply * rep, int accel)
748 {
749 int type;
750
751 if (!auth_user_request)
752 return;
753
754
755 /* has the header already been send? */
756 if (flags.authinfo_sent)
757 return;
758
759 /* don't add to authentication error pages */
760 if ((!accel && rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED)
761 || (accel && rep->sline.status == HTTP_UNAUTHORIZED))
762 return;
763
764 type = accel ? HDR_AUTHENTICATION_INFO : HDR_PROXY_AUTHENTICATION_INFO;
765
766 if ((digestConfig.authenticate) && authDigestNonceLastRequest(nonce)) {
767 debugs(29, 9, "authDigestAddTrailer: Sending type:" << type << " header: 'nextnonce=\"" << authenticateDigestNonceNonceb64(nonce) << "\"");
768 httpTrailerPutStrf(&rep->header, type, "nextnonce=\"%s\"", authenticateDigestNonceNonceb64(nonce));
769 }
770 }
771
772 #endif
773
774 /* add the [www-|Proxy-]authenticate header on a 407 or 401 reply */
775 void
776 AuthDigestConfig::fixHeader(AuthUserRequest *auth_user_request, HttpReply *rep, http_hdr_type type, HttpRequest * request)
777 {
778 if (!authenticate)
779 return;
780
781 int stale = 0;
782
783 if (auth_user_request) {
784 AuthDigestUserRequest *digest_request;
785 digest_request = dynamic_cast < AuthDigestUserRequest * >(auth_user_request);
786 assert (digest_request != NULL);
787
788 stale = !digest_request->flags.invalid_password;
789 }
790
791 /* on a 407 or 401 we always use a new nonce */
792 digest_nonce_h *nonce = authenticateDigestNonceNew();
793
794 debugs(29, 9, "authenticateFixHeader: Sending type:" << type <<
795 " header: 'Digest realm=\"" << digestAuthRealm << "\", nonce=\"" <<
796 authenticateDigestNonceNonceb64(nonce) << "\", qop=\"" << QOP_AUTH <<
797 "\", stale=" << (stale ? "true" : "false"));
798
799 /* in the future, for WWW auth we may want to support the domain entry */
800 httpHeaderPutStrf(&rep->header, type, "Digest realm=\"%s\", nonce=\"%s\", qop=\"%s\", stale=%s", digestAuthRealm, authenticateDigestNonceNonceb64(nonce), QOP_AUTH, stale ? "true" : "false");
801 }
802
803 DigestUser::~DigestUser()
804 {
805
806 dlink_node *link, *tmplink;
807 link = nonces.head;
808
809 while (link) {
810 tmplink = link;
811 link = link->next;
812 dlinkDelete(tmplink, &nonces);
813 authDigestNoncePurge(static_cast < digest_nonce_h * >(tmplink->data));
814 authDigestNonceUnlink(static_cast < digest_nonce_h * >(tmplink->data));
815 dlinkNodeDelete(tmplink);
816 }
817 }
818
819 static void
820 authenticateDigestHandleReply(void *data, char *reply)
821 {
822 DigestAuthenticateStateData *replyData = static_cast < DigestAuthenticateStateData * >(data);
823 AuthUserRequest *auth_user_request;
824 AuthDigestUserRequest *digest_request;
825 digest_user_h *digest_user;
826 char *t = NULL;
827 void *cbdata;
828 debugs(29, 9, "authenticateDigestHandleReply: {" << (reply ? reply : "<NULL>") << "}");
829
830 if (reply) {
831 if ((t = strchr(reply, ' ')))
832 *t++ = '\0';
833
834 if (*reply == '\0' || *reply == '\n')
835 reply = NULL;
836 }
837
838 assert(replyData->auth_user_request != NULL);
839 auth_user_request = replyData->auth_user_request;
840 digest_request = dynamic_cast < AuthDigestUserRequest * >(auth_user_request);
841 assert(digest_request);
842
843 digest_user = dynamic_cast < digest_user_h * >(auth_user_request->user());
844 assert(digest_user != NULL);
845
846 if (reply && (strncasecmp(reply, "ERR", 3) == 0)) {
847 digest_request->credentials(AuthDigestUserRequest::Failed);
848 digest_request->flags.invalid_password = 1;
849
850 if (t && *t)
851 digest_request->setDenyMessage(t);
852 } else if (reply) {
853 CvtBin(reply, digest_user->HA1);
854 digest_user->HA1created = 1;
855 }
856
857 if (cbdataReferenceValidDone(replyData->data, &cbdata))
858 replyData->handler(cbdata, NULL);
859
860 //we know replyData->auth_user_request != NULL, or we'd have asserted
861 AUTHUSERREQUESTUNLOCK(replyData->auth_user_request, "replyData");
862
863 cbdataFree(replyData);
864 }
865
866 /* Initialize helpers and the like for this auth scheme. Called AFTER parsing the
867 * config file */
868 void
869 AuthDigestConfig::init(AuthConfig * scheme)
870 {
871 if (authenticate) {
872 authenticateDigestNonceSetup();
873 authdigest_initialised = 1;
874
875 if (digestauthenticators == NULL)
876 digestauthenticators = helperCreate("digestauthenticator");
877
878 digestauthenticators->cmdline = authenticate;
879
880 digestauthenticators->n_to_start = authenticateChildren;
881
882 digestauthenticators->ipc_type = IPC_STREAM;
883
884 helperOpenServers(digestauthenticators);
885
886 CBDATA_INIT_TYPE(DigestAuthenticateStateData);
887 }
888 }
889
890 void
891 AuthDigestConfig::registerWithCacheManager(void)
892 {
893 CacheManager::GetInstance()->
894 registerAction("digestauthenticator",
895 "Digest User Authenticator Stats",
896 authenticateDigestStats, 0, 1);
897 }
898
899 /* free any allocated configuration details */
900 void
901 AuthDigestConfig::done()
902 {
903 if (authenticate)
904 wordlistDestroy(&authenticate);
905
906 safe_free(digestAuthRealm);
907 }
908
909
910 AuthDigestConfig::AuthDigestConfig()
911 {
912 /* TODO: move into initialisation list */
913 authenticateChildren = 5;
914 /* 5 minutes */
915 nonceGCInterval = 5 * 60;
916 /* 30 minutes */
917 noncemaxduration = 30 * 60;
918 /* 50 requests */
919 noncemaxuses = 50;
920 /* Not strict nonce count behaviour */
921 NonceStrictness = 0;
922 /* Verify nonce count */
923 CheckNonceCount = 1;
924 }
925
926 void
927 AuthDigestConfig::parse(AuthConfig * scheme, int n_configured, char *param_str)
928 {
929 if (strcasecmp(param_str, "program") == 0) {
930 if (authenticate)
931 wordlistDestroy(&authenticate);
932
933 parse_wordlist(&authenticate);
934
935 requirePathnameExists("auth_param digest program", authenticate->key);
936 } else if (strcasecmp(param_str, "children") == 0) {
937 parse_int(&authenticateChildren);
938 } else if (strcasecmp(param_str, "realm") == 0) {
939 parse_eol(&digestAuthRealm);
940 } else if (strcasecmp(param_str, "nonce_garbage_interval") == 0) {
941 parse_time_t(&nonceGCInterval);
942 } else if (strcasecmp(param_str, "nonce_max_duration") == 0) {
943 parse_time_t(&noncemaxduration);
944 } else if (strcasecmp(param_str, "nonce_max_count") == 0) {
945 parse_int((int *) &noncemaxuses);
946 } else if (strcasecmp(param_str, "nonce_strictness") == 0) {
947 parse_onoff(&NonceStrictness);
948 } else if (strcasecmp(param_str, "check_nonce_count") == 0) {
949 parse_onoff(&CheckNonceCount);
950 } else if (strcasecmp(param_str, "post_workaround") == 0) {
951 parse_onoff(&PostWorkaround);
952 } else if (strcasecmp(param_str, "utf8") == 0) {
953 parse_onoff(&utf8);
954 } else {
955 debugs(29, 0, "unrecognised digest auth scheme parameter '" << param_str << "'");
956 }
957 }
958
959 const char *
960 AuthDigestConfig::type() const
961 {
962 return digestScheme::GetInstance().type();
963 }
964
965
966 static void
967 authenticateDigestStats(StoreEntry * sentry)
968 {
969 helperStats(sentry, digestauthenticators, "Digest Authenticator Statistics");
970 }
971
972 /* NonceUserUnlink: remove the reference to auth_user and unlink the node from the list */
973
974 static void
975 authDigestNonceUserUnlink(digest_nonce_h * nonce)
976 {
977 digest_user_h *digest_user;
978 dlink_node *link, *tmplink;
979
980 if (!nonce)
981 return;
982
983 if (!nonce->user)
984 return;
985
986 digest_user = nonce->user;
987
988 /* unlink from the user list. Yes we're crossing structures but this is the only
989 * time this code is needed
990 */
991 link = digest_user->nonces.head;
992
993 while (link) {
994 tmplink = link;
995 link = link->next;
996
997 if (tmplink->data == nonce) {
998 dlinkDelete(tmplink, &digest_user->nonces);
999 authDigestNonceUnlink(static_cast < digest_nonce_h * >(tmplink->data));
1000 dlinkNodeDelete(tmplink);
1001 link = NULL;
1002 }
1003 }
1004
1005 /* this reference to user was not locked because freeeing the user frees
1006 * the nonce too.
1007 */
1008 nonce->user = NULL;
1009 }
1010
1011 /* authDigestUserLinkNonce: add a nonce to a given user's struct */
1012
1013 static void
1014 authDigestUserLinkNonce(DigestUser * user, digest_nonce_h * nonce)
1015 {
1016 dlink_node *node;
1017 digest_user_h *digest_user;
1018
1019 if (!user || !nonce)
1020 return;
1021
1022 digest_user = user;
1023
1024 node = digest_user->nonces.head;
1025
1026 while (node && (node->data != nonce))
1027 node = node->next;
1028
1029 if (node)
1030 return;
1031
1032 node = dlinkNodeNew();
1033
1034 dlinkAddTail(nonce, node, &digest_user->nonces);
1035
1036 authDigestNonceLink(nonce);
1037
1038 /* ping this nonce to this auth user */
1039 assert((nonce->user == NULL) || (nonce->user = user));
1040
1041 /* we don't lock this reference because removing the user removes the
1042 * hash too. Of course if that changes we're stuffed so read the code huh?
1043 */
1044 nonce->user = user;
1045 }
1046
1047 /* setup the necessary info to log the username */
1048 static AuthUserRequest *
1049 authDigestLogUsername(char *username, AuthDigestUserRequest *auth_user_request)
1050 {
1051 assert(auth_user_request != NULL);
1052
1053 /* log the username */
1054 debugs(29, 9, "authDigestLogUsername: Creating new user for logging '" << username << "'");
1055 digest_user_h *digest_user = new DigestUser(&digestConfig);
1056 /* save the credentials */
1057 digest_user->username(username);
1058 /* set the auth_user type */
1059 digest_user->auth_type = AUTH_BROKEN;
1060 /* link the request to the user */
1061 auth_user_request->authUser(digest_user);
1062 auth_user_request->user(digest_user);
1063 digest_user->addRequest (auth_user_request);
1064 return auth_user_request;
1065 }
1066
1067 /*
1068 * Decode a Digest [Proxy-]Auth string, placing the results in the passed
1069 * Auth_user structure.
1070 */
1071 AuthUserRequest *
1072 AuthDigestConfig::decode(char const *proxy_auth)
1073 {
1074 const char *item;
1075 const char *p;
1076 const char *pos = NULL;
1077 char *username = NULL;
1078 digest_nonce_h *nonce;
1079 int ilen;
1080
1081 debugs(29, 9, "authenticateDigestDecodeAuth: beginning");
1082
1083 AuthDigestUserRequest *digest_request = new AuthDigestUserRequest();
1084
1085 /* trim DIGEST from string */
1086
1087 while (xisgraph(*proxy_auth))
1088 proxy_auth++;
1089
1090 /* Trim leading whitespace before decoding */
1091 while (xisspace(*proxy_auth))
1092 proxy_auth++;
1093
1094 String temp(proxy_auth);
1095
1096 while (strListGetItem(&temp, ',', &item, &ilen, &pos)) {
1097 if ((p = strchr(item, '=')) && (p - item < ilen))
1098 ilen = p++ - item;
1099
1100 if (!strncmp(item, "username", ilen)) {
1101 /* white space */
1102
1103 while (xisspace(*p))
1104 p++;
1105
1106 /* quote mark */
1107 p++;
1108
1109 username = xstrndup(p, strchr(p, '"') + 1 - p);
1110
1111 debugs(29, 9, "authDigestDecodeAuth: Found Username '" << username << "'");
1112 } else if (!strncmp(item, "realm", ilen)) {
1113 /* white space */
1114
1115 while (xisspace(*p))
1116 p++;
1117
1118 /* quote mark */
1119 p++;
1120
1121 digest_request->realm = xstrndup(p, strchr(p, '"') + 1 - p);
1122
1123 debugs(29, 9, "authDigestDecodeAuth: Found realm '" << digest_request->realm << "'");
1124 } else if (!strncmp(item, "qop", ilen)) {
1125 /* white space */
1126
1127 while (xisspace(*p))
1128 p++;
1129
1130 if (*p == '\"')
1131 /* quote mark */
1132 p++;
1133
1134 digest_request->qop = xstrndup(p, strcspn(p, "\" \t\r\n()<>@,;:\\/[]?={}") + 1);
1135
1136 debugs(29, 9, "authDigestDecodeAuth: Found qop '" << digest_request->qop << "'");
1137 } else if (!strncmp(item, "algorithm", ilen)) {
1138 /* white space */
1139
1140 while (xisspace(*p))
1141 p++;
1142
1143 if (*p == '\"')
1144 /* quote mark */
1145 p++;
1146
1147 digest_request->algorithm = xstrndup(p, strcspn(p, "\" \t\r\n()<>@,;:\\/[]?={}") + 1);
1148
1149 debugs(29, 9, "authDigestDecodeAuth: Found algorithm '" << digest_request->algorithm << "'");
1150 } else if (!strncmp(item, "uri", ilen)) {
1151 /* white space */
1152
1153 while (xisspace(*p))
1154 p++;
1155
1156 /* quote mark */
1157 p++;
1158
1159 digest_request->uri = xstrndup(p, strchr(p, '"') + 1 - p);
1160
1161 debugs(29, 9, "authDigestDecodeAuth: Found uri '" << digest_request->uri << "'");
1162 } else if (!strncmp(item, "nonce", ilen)) {
1163 /* white space */
1164
1165 while (xisspace(*p))
1166 p++;
1167
1168 /* quote mark */
1169 p++;
1170
1171 digest_request->nonceb64 = xstrndup(p, strchr(p, '"') + 1 - p);
1172
1173 debugs(29, 9, "authDigestDecodeAuth: Found nonce '" << digest_request->nonceb64 << "'");
1174 } else if (!strncmp(item, "nc", ilen)) {
1175 /* white space */
1176
1177 while (xisspace(*p))
1178 p++;
1179
1180 xstrncpy(digest_request->nc, p, 9);
1181
1182 debugs(29, 9, "authDigestDecodeAuth: Found noncecount '" << digest_request->nc << "'");
1183 } else if (!strncmp(item, "cnonce", ilen)) {
1184 /* white space */
1185
1186 while (xisspace(*p))
1187 p++;
1188
1189 /* quote mark */
1190 p++;
1191
1192 digest_request->cnonce = xstrndup(p, strchr(p, '"') + 1 - p);
1193
1194 debugs(29, 9, "authDigestDecodeAuth: Found cnonce '" << digest_request->cnonce << "'");
1195 } else if (!strncmp(item, "response", ilen)) {
1196 /* white space */
1197
1198 while (xisspace(*p))
1199 p++;
1200
1201 /* quote mark */
1202 p++;
1203
1204 digest_request->response = xstrndup(p, strchr(p, '"') + 1 - p);
1205
1206 debugs(29, 9, "authDigestDecodeAuth: Found response '" << digest_request->response << "'");
1207 }
1208 }
1209
1210 temp.clean();
1211
1212
1213 /* now we validate the data given to us */
1214
1215 /*
1216 * TODO: on invalid parameters we should return 400, not 407.
1217 * Find some clean way of doing this. perhaps return a valid
1218 * struct, and set the direction to clientwards combined with
1219 * a change to the clientwards handling code (ie let the
1220 * clientwards call set the error type (but limited to known
1221 * correct values - 400/401/407
1222 */
1223
1224 /* first the NONCE count */
1225
1226 if (digest_request->cnonce && strlen(digest_request->nc) != 8) {
1227 debugs(29, 4, "authenticateDigestDecode: nonce count length invalid");
1228 return authDigestLogUsername(username, digest_request);
1229 }
1230
1231 /* now the nonce */
1232 nonce = authenticateDigestNonceFindNonce(digest_request->nonceb64);
1233
1234 if (!nonce) {
1235 /* we couldn't find a matching nonce! */
1236 debugs(29, 4, "authenticateDigestDecode: Unexpected or invalid nonce received");
1237 return authDigestLogUsername(username, digest_request);
1238 }
1239
1240 digest_request->nonce = nonce;
1241 authDigestNonceLink(nonce);
1242
1243 /* check the qop is what we expected. Note that for compatability with
1244 * RFC 2069 we should support a missing qop. Tough. */
1245
1246 if (digest_request->qop && strcmp(digest_request->qop, QOP_AUTH) != 0) {
1247 /* we received a qop option we didn't send */
1248 debugs(29, 4, "authenticateDigestDecode: Invalid qop option received");
1249 return authDigestLogUsername(username, digest_request);
1250 }
1251
1252 /* we can't check the URI just yet. We'll check it in the
1253 * authenticate phase */
1254
1255 /* is the response the correct length? */
1256
1257 if (!digest_request->response || strlen(digest_request->response) != 32) {
1258 debugs(29, 4, "authenticateDigestDecode: Response length invalid");
1259 return authDigestLogUsername(username, digest_request);
1260 }
1261
1262 /* do we have a username ? */
1263 if (!username || username[0] == '\0') {
1264 debugs(29, 4, "authenticateDigestDecode: Empty or not present username");
1265 return authDigestLogUsername(username, digest_request);
1266 }
1267
1268 /* check that we're not being hacked / the username hasn't changed */
1269 if (nonce->user && strcmp(username, nonce->user->username())) {
1270 debugs(29, 4, "authenticateDigestDecode: Username for the nonce does not equal the username for the request");
1271 return authDigestLogUsername(username, digest_request);
1272 }
1273
1274 /* if we got a qop, did we get a cnonce or did we get a cnonce wihtout a qop? */
1275 if ((digest_request->qop && !digest_request->cnonce)
1276 || (!digest_request->qop && digest_request->cnonce)) {
1277 debugs(29, 4, "authenticateDigestDecode: qop without cnonce, or vice versa!");
1278 return authDigestLogUsername(username, digest_request);
1279 }
1280
1281 /* check the algorithm is present and supported */
1282 if (!digest_request->algorithm)
1283 digest_request->algorithm = xstrndup("MD5", 4);
1284 else if (strcmp(digest_request->algorithm, "MD5")
1285 && strcmp(digest_request->algorithm, "MD5-sess")) {
1286 debugs(29, 4, "authenticateDigestDecode: invalid algorithm specified!");
1287 return authDigestLogUsername(username, digest_request);
1288 }
1289
1290 /* the method we'll check at the authenticate step as well */
1291
1292
1293 /* we don't send or parse opaques. Ok so we're flexable ... */
1294
1295 /* find the user */
1296 digest_user_h *digest_user;
1297
1298 AuthUser *auth_user;
1299
1300 if ((auth_user = authDigestUserFindUsername(username)) == NULL) {
1301 /* the user doesn't exist in the username cache yet */
1302 debugs(29, 9, "authDigestDecodeAuth: Creating new digest user '" << username << "'");
1303 digest_user = new DigestUser (&digestConfig);
1304 /* auth_user is a parent */
1305 auth_user = digest_user;
1306 /* save the username */
1307 digest_user->username(username);
1308 /* set the user type */
1309 digest_user->auth_type = AUTH_DIGEST;
1310 /* this auth_user struct is the one to get added to the
1311 * username cache */
1312 /* store user in hash's */
1313 digest_user->addToNameCache();
1314
1315 /*
1316 * Add the digest to the user so we can tell if a hacking
1317 * or spoofing attack is taking place. We do this by assuming
1318 * the user agent won't change user name without warning.
1319 */
1320 authDigestUserLinkNonce(digest_user, nonce);
1321 } else {
1322 debugs(29, 9, "authDigestDecodeAuth: Found user '" << username << "' in the user cache as '" << auth_user << "'");
1323 digest_user = static_cast < digest_user_h * >(auth_user);
1324 xfree(username);
1325 }
1326
1327 /*link the request and the user */
1328 assert(digest_request != NULL);
1329
1330 digest_request->authUser (digest_user);
1331
1332 digest_request->user(digest_user);
1333
1334 digest_user->addRequest (digest_request);
1335
1336 debugs(29, 9, "username = '" << digest_user->username() << "'\nrealm = '" <<
1337 digest_request->realm << "'\nqop = '" << digest_request->qop <<
1338 "'\nalgorithm = '" << digest_request->algorithm << "'\nuri = '" <<
1339 digest_request->uri << "'\nnonce = '" << digest_request->nonceb64 <<
1340 "'\nnc = '" << digest_request->nc << "'\ncnonce = '" <<
1341 digest_request->cnonce << "'\nresponse = '" <<
1342 digest_request->response << "'\ndigestnonce = '" << nonce << "'");
1343
1344 return digest_request;
1345 }
1346
1347 /* send the initial data to a digest authenticator module */
1348 void
1349 AuthDigestUserRequest::module_start(RH * handler, void *data)
1350 {
1351 DigestAuthenticateStateData *r = NULL;
1352 char buf[8192];
1353 digest_user_h *digest_user;
1354 assert(user()->auth_type == AUTH_DIGEST);
1355 digest_user = dynamic_cast < digest_user_h * >(user());
1356 assert(digest_user != NULL);
1357 debugs(29, 9, "authenticateStart: '\"" << digest_user->username() << "\":\"" << realm << "\"'");
1358
1359 if (digestConfig.authenticate == NULL) {
1360 handler(data, NULL);
1361 return;
1362 }
1363
1364 r = cbdataAlloc(DigestAuthenticateStateData);
1365 r->handler = handler;
1366 r->data = cbdataReference(data);
1367 r->auth_user_request = this;
1368 AUTHUSERREQUESTLOCK(r->auth_user_request, "r");
1369 if (digestConfig.utf8) {
1370 char user[1024];
1371 latin1_to_utf8(user, sizeof(user), digest_user->username());
1372 snprintf(buf, 8192, "\"%s\":\"%s\"\n", user, realm);
1373 } else {
1374 snprintf(buf, 8192, "\"%s\":\"%s\"\n", digest_user->username(), realm);
1375 }
1376
1377 helperSubmit(digestauthenticators, buf, authenticateDigestHandleReply, r);
1378 }
1379
1380 DigestUser::DigestUser (AuthConfig *config) : AuthUser (config), HA1created (0)
1381 {}
1382
1383 AuthUser *
1384 AuthDigestUserRequest::authUser() const
1385 {
1386 return const_cast<AuthUser *>(user());
1387 }
1388
1389 void
1390 AuthDigestUserRequest::authUser(AuthUser *aUser)
1391 {
1392 assert(!authUser());
1393 user(aUser);
1394 user()->lock();
1395 }
1396
1397 AuthDigestUserRequest::CredentialsState
1398 AuthDigestUserRequest::credentials() const
1399 {
1400 return credentials_ok;
1401 }
1402
1403 void
1404 AuthDigestUserRequest::credentials(CredentialsState newCreds)
1405 {
1406 credentials_ok = newCreds;
1407 }
1408
1409 AuthDigestUserRequest::AuthDigestUserRequest() : nonceb64(NULL) ,cnonce(NULL) ,realm(NULL),
1410 pszPass(NULL) ,algorithm(NULL) ,pszMethod(NULL),
1411 qop(NULL) ,uri(NULL) ,response(NULL),
1412 nonce(NULL), _theUser (NULL) ,
1413 credentials_ok (Unchecked)
1414 {}
1415
1416 /** delete the digest request structure. Does NOT delete related structures */
1417 AuthDigestUserRequest::~AuthDigestUserRequest()
1418 {
1419 safe_free (nonceb64);
1420 safe_free (cnonce);
1421 safe_free (realm);
1422 safe_free (pszPass);
1423 safe_free (algorithm);
1424 safe_free (pszMethod);
1425 safe_free (qop);
1426 safe_free (uri);
1427 safe_free (response);
1428
1429 if (nonce)
1430 authDigestNonceUnlink(nonce);
1431 }
1432
1433 AuthConfig *
1434 digestScheme::createConfig()
1435 {
1436 return &digestConfig;
1437 }
1438