]>
git.ipfire.org Git - thirdparty/squid.git/blob - helpers/digest_auth/file/digest_file_auth.cc
4 * AUTHOR: Robert Collins. Based on ncsa_auth.c by Arjan de Vet
5 * <Arjan.deVet@adv.iae.nl>
6 * LDAP backend extension by Flavio Pescuma, MARA Systems AB <flavio@marasystems.com>
8 * Example digest authentication program for Squid, based on the original
9 * proxy_auth code from client_side.c, written by
10 * Jon Thackray <jrmt@uk.gdscorp.com>.
12 * - comment lines are possible and should start with a '#';
13 * - empty or blank lines are possible;
14 * - file format is username:password
16 * To build a directory integrated backend, you need to be able to
17 * calculate the HA1 returned to squid. To avoid storing a plaintext
18 * password you can calculate MD5(username:realm:password) when the
19 * user changes their password, and store the tuple username:realm:HA1.
20 * then find the matching username:realm when squid asks for the
23 * This implementation could be improved by using such a triple for
24 * the file format. However storing such a triple does little to
25 * improve security: If compromised the username:realm:HA1 combination
26 * is "plaintext equivalent" - for the purposes of digest authentication
27 * they allow the user access. Password syncronisation is not tackled
28 * by digest - just preventing on the wire compromise.
30 * Copyright (c) 2003 Robert Collins <robertc@squid-cache.org>
34 #include "digest_common.h"
35 #include "text_backend.h"
37 #define PROGRAM_NAME "digest_file_auth"
40 GetHHA1(RequestData
* requestData
)
42 TextHHA1(requestData
);
46 ParseBuffer(char *buf
, RequestData
* requestData
)
49 requestData
->parsed
= 0;
50 if ((p
= strchr(buf
, '\n')) != NULL
)
51 *p
= '\0'; /* strip \n */
52 if ((requestData
->user
= strtok(buf
, "\"")) == NULL
)
54 if ((requestData
->realm
= strtok(NULL
, "\"")) == NULL
)
56 if ((requestData
->realm
= strtok(NULL
, "\"")) == NULL
)
58 requestData
->parsed
= -1;
62 OutputHHA1(RequestData
* requestData
)
64 requestData
->error
= 0;
66 if (requestData
->error
) {
67 printf("ERR No such user\n");
70 printf("%s\n", requestData
->HHA1
);
74 DoOneRequest(char *buf
)
76 RequestData requestData
;
77 ParseBuffer(buf
, &requestData
);
78 if (!requestData
.parsed
) {
82 OutputHHA1(&requestData
);
86 ProcessArguments(int argc
, char **argv
)
88 TextArguments(argc
, argv
);
92 main(int argc
, char **argv
)
96 ProcessArguments(argc
, argv
);
97 while (fgets(buf
, 256, stdin
) != NULL
)