3 # A form for editing authentication programs
5 require './squid-lib.pl';
6 $access{'authparam'} || &error($text{'authparam_ecannot'});
7 &ui_print_header(undef, $text{'authparam_title'}, "", "edit_authparam", 0, 0, 0,
11 print "<form action=save_authparam.cgi>\n";
12 print "<table border width=100%>\n";
13 print "<tr $tb> <td><b>$text{'authparam_header'}</b></td> </tr>\n";
14 print "<tr $cb> <td><table width=100%>\n";
16 if ($squid_version >= 2.5) {
17 # Squid versions 2.5 and above use different config options for
18 # the external authentication program
19 local @auth = &find_config("auth_param", $conf);
21 # Show basic authentication options
22 local %basic = map { $_->{'values'}->[1], $_->{'values'} }
23 grep { $_->{'values'}->[0] eq 'basic' } @auth;
24 print "<tr> <td valign=top><b>$text{'authparam_bprogram'}</b></td>\n";
25 print "<td nowrap>\n";
26 local @p = @{$basic{'program'}};
28 $p[2] =~ /^(\S+)/ && $1 eq $auth_program ? 2 : 1;
29 printf "<input type=radio name=b_auth_mode value=0 %s> %s\n",
30 $m == 0 ? "checked" : "", $text{'none'};
31 printf "<input type=radio name=b_auth_mode value=2 %s> %s\n",
32 $m == 2 ? "checked" : "", $text{'eprogs_capweb'};
33 printf "<input type=radio name=b_auth_mode value=1 %s>\n",
34 $m == 1 ? "checked" : "";
35 printf "<input name=b_auth size=40 value='%s'> %s</td>\n",
36 $m == 1 ? join(" ", @p[2..$#p]) : "",
37 &file_chooser_button("b_auth");
40 local $c = $basic{'children'}->[2];
41 print "<tr> <td><b>$text{'eprogs_noap'}</b></td> <td nowrap>\n";
42 printf "<input type=radio name=b_children_def value=1 %s> %s\n",
43 $c eq "" ? "checked" : "", $text{'default'};
44 printf "<input type=radio name=b_children_def value=0 %s>\n",
45 $c eq "" ? "" : "checked";
46 printf "<input name=b_children size=5 value='%s'></td> </tr>\n", $c;
48 local @t = @{$basic{'credentialsttl'}};
49 print "<tr> <td><b>$text{'eprogs_ttl'}</b></td>\n";
50 printf "<td nowrap><input type=radio name=b_ttl_def value=1 %s> %s\n",
51 !@t ? "checked" : "", $text{'default'};
52 printf "<input type=radio name=b_ttl_def value=0 %s>\n",
54 print &time_fields("b_ttl", 6, $t[2], $t[3]),"</td>\n";
56 local @r = @{$basic{'realm'}};
57 local $r = join(" ", @r[2..$#r]);
58 print "<tr> <td><b>$text{'eprogs_realm'}</b></td> <td>\n";
59 printf "<input type=radio name=b_realm_def value=1 %s> %s\n",
60 $r eq "" ? "checked" : "", $text{'default'};
61 printf "<input type=radio name=b_realm_def value=0 %s>\n",
62 $r eq "" ? "" : "checked";
63 printf "<input name=b_realm size=40 value='%s'></td> </tr>\n", $r;
65 # Show digest authentication options
66 print "<tr> <td colspan=2><hr></td> </tr>\n";
67 local %digest = map { $_->{'values'}->[1], $_->{'values'} }
68 grep { $_->{'values'}->[0] eq 'digest' } @auth;
69 print "<tr> <td valign=top><b>$text{'authparam_dprogram'}</b></td>\n";
70 print "<td nowrap>\n";
71 local @p = @{$digest{'program'}};
72 local $m = @p ? 1 : 0;
73 printf "<input type=radio name=d_auth_mode value=0 %s> %s\n",
74 $m == 0 ? "checked" : "", $text{'none'};
75 printf "<input type=radio name=d_auth_mode value=1 %s>\n",
76 $m == 1 ? "checked" : "";
77 printf "<input name=d_auth size=40 value='%s'> %s</td>\n",
78 $m == 1 ? join(" ", @p[2..$#p]) : "",
79 &file_chooser_button("d_auth");
82 local $c = $digest{'children'}->[2];
83 print "<tr> <td><b>$text{'eprogs_noap'}</b></td> <td nowrap>\n";
84 printf "<input type=radio name=d_children_def value=1 %s> %s\n",
85 $c eq "" ? "checked" : "", $text{'default'};
86 printf "<input type=radio name=d_children_def value=0 %s>\n",
87 $c eq "" ? "" : "checked";
88 printf "<input name=d_children size=5 value='%s'></td>\n", $c;
90 local @r = @{$digest{'realm'}};
91 local $r = join(" ", @r[2..$#r]);
92 print "<tr> <td><b>$text{'eprogs_realm'}</b></td> <td>\n";
93 printf "<input type=radio name=d_realm_def value=1 %s> %s\n",
94 $r eq "" ? "checked" : "", $text{'default'};
95 printf "<input type=radio name=d_realm_def value=0 %s>\n",
96 $r eq "" ? "" : "checked";
97 printf "<input name=d_realm size=40 value='%s'></td> </tr>\n", $r;
99 # Show NTML authentication options
100 print "<tr> <td colspan=2><hr></td> </tr>\n";
101 local %ntlm = map { $_->{'values'}->[1], $_->{'values'} }
102 grep { $_->{'values'}->[0] eq 'ntlm' } @auth;
103 print "<tr> <td valign=top><b>$text{'authparam_nprogram'}</b></td>\n";
104 print "<td nowrap>\n";
105 local @p = @{$ntlm{'program'}};
106 local $m = @p ? 1 : 0;
107 printf "<input type=radio name=n_auth_mode value=0 %s> %s\n",
108 $m == 0 ? "checked" : "", $text{'none'};
109 printf "<input type=radio name=n_auth_mode value=1 %s>\n",
110 $m == 1 ? "checked" : "";
111 printf "<input name=n_auth size=40 value='%s'> %s</td>\n",
112 $m == 1 ? join(" ", @p[2..$#p]) : "",
113 &file_chooser_button("n_auth");
116 local $c = $ntlm{'children'}->[2];
117 print "<tr> <td><b>$text{'eprogs_noap'}</b></td> <td nowrap>\n";
118 printf "<input type=radio name=n_children_def value=1 %s> %s\n",
119 $c eq "" ? "checked" : "", $text{'default'};
120 printf "<input type=radio name=n_children_def value=0 %s>\n",
121 $c eq "" ? "" : "checked";
122 printf "<input name=n_children size=5 value='%s'></td> </tr>\n", $c;
124 local $r = $ntlm{'max_challenge_reuses'}->[2];
125 print "<tr> <td><b>$text{'authparam_reuses'}</b></td> <td nowrap>\n";
126 printf "<input type=radio name=n_reuses_def value=1 %s> %s\n",
127 $r eq "" ? "checked" : "", $text{'default'};
128 printf "<input type=radio name=n_reuses_def value=0 %s>\n",
129 $r eq "" ? "" : "checked";
130 printf "<input name=n_reuses size=5 value='%s'></td> </tr>\n", $r;
132 local @t = @{$ntlm{'max_challenge_lifetime'}};
133 print "<tr> <td><b>$text{'authparam_lifetime'}</b></td>\n";
134 printf "<td nowrap><input type=radio name=n_ttl_def value=1 %s> %s\n",
135 !@t ? "checked" : "", $text{'default'};
136 printf "<input type=radio name=n_ttl_def value=0 %s>\n",
137 !@t ? "" : "checked";
138 print &time_fields("n_ttl", 6, $t[2], $t[3]),"</td> </tr>\n";
140 elsif ($squid_version >= 2) {
141 # Squid versions 2 and above use a single external
142 # authentication program
144 local $v = &find_config("authenticate_program", $conf);
145 print "<td valign=top><b>$text{'eprogs_cap'}</b></td>\n";
146 print "<td nowrap>\n";
148 $v->{'value'} =~ /^(\S+)/ && $1 eq $auth_program ? 2 : 1;
149 printf "<input type=radio name=auth_mode value=0 %s> %s\n",
150 $m == 0 ? "checked" : "", $text{'none'};
151 printf "<input type=radio name=auth_mode value=2 %s> %s\n",
152 $m == 2 ? "checked" : "", $text{'eprogs_capweb'};
153 printf "<input type=radio name=auth_mode value=1 %s>\n",
154 $m == 1 ? "checked" : "";
155 printf "<input name=auth size=40 value='%s'> %s</td>\n",
156 $m == 1 ? $v->{'value'} : "", &file_chooser_button("auth");
160 print &opt_input($text{'eadm_par'}, "proxy_auth_realm",
161 $conf, $text{'eadm_default'}, 40);
165 print &opt_input($text{'eprogs_noap'},
166 "authenticate_children", $conf, $text{'default'}, 6);
169 if ($squid_version >= 2.4) {
171 print &opt_time_input($text{'authparam_ttl'},
172 "authenticate_ttl", $conf, $text{'default'}, 6);
175 print &opt_time_input($text{'authparam_ipttl'},
176 "authenticate_ip_ttl", $conf, $text{'authparam_never'}, 6);
180 print "<tr> <td colspan=2><hr></td> </tr>\n";
181 print "<tr> <td colspan=2>".$text{'authparam_mui_msg'}."</td> </tr>\n";
182 print "<tr> <td colspan=2><hr></td> </tr>\n";
184 local $taa = &find_value("authenticate_ip_ttl", $conf);
186 (@ta[0],@ta[1])=split(/\s+/,$taa);
188 print "<tr> <td><b>$text{'eprogs_aittl'}</b></td>\n";
189 printf "<td nowrap><input type=radio name=b_aittl_def value=1 %s> %s\n",
190 !@ta ? "checked" : "", $text{'default'};
191 printf "<input type=radio name=b_aittl_def value=0 %s>\n",
192 !@ta ? "" : "checked";
193 print &time_fields("b_aittl", 6, $ta[0], $ta[1]),"</td></tr>\n";
194 print "<tr> <td colspan=2><hr></td> </tr>\n";
196 print "</table></td></tr></table>\n";
197 print "<input type=submit value='$text{'buttsave'}'></form>\n";
199 &ui_print_footer("", $text{'eprogs_return'});