httpauth: If REMOTE_USER is empty, behave as though it was unset

A frequently cut-and-pasted HTTP basic authentication configuration
for nginx sets it to the empty string when not authenticated, which
is not useful.
master
Simon McVittie 2017-05-14 14:44:43 +01:00
parent 59daf36cb2
commit 31c89db246
3 changed files with 10 additions and 3 deletions

View File

@ -66,7 +66,7 @@ sub auth ($$) {
my $cgi=shift;
my $session=shift;
if (defined $cgi->remote_user()) {
if (length $cgi->remote_user()) {
$session->param("name", $cgi->remote_user());
}
}
@ -80,7 +80,7 @@ sub formbuilder_setup (@) {
my $buttons=$params{buttons};
if ($form->title eq "signin" &&
! defined $cgi->remote_user() && defined $config{cgiauthurl}) {
! length $cgi->remote_user() && defined $config{cgiauthurl}) {
my $button_text="Login with HTTP auth";
push @$buttons, $button_text;
@ -97,7 +97,7 @@ sub canedit ($$$) {
my $cgi=shift;
my $session=shift;
if (! defined $cgi->remote_user() &&
if (! length $cgi->remote_user() &&
(! defined $session->param("name") ||
! IkiWiki::userinfo_get($session->param("name"), "regdate")) &&
defined $config{httpauth_pagespec} &&

3
debian/changelog vendored
View File

@ -3,6 +3,9 @@ ikiwiki (3.20170112) UNRELEASED; urgency=medium
* t/git-cgi.t: Wait 1 second before doing a revert that should work.
This hopefully fixes a race condition in which the test failed
around 6% of the time. (Closes: 862494)
* Guard against set-but-empty REMOTE_USER CGI variable on
misconfigured nginx servers, and in general treat sessions with
a set-but-empty name as if they were not signed in.
-- Simon McVittie <smcv@debian.org> Sun, 14 May 2017 15:34:52 +0100

View File

@ -81,6 +81,10 @@ It seems I can't log out from nowhere. I've rebuild the wiki from the command li
> with one of a limited set of authorized usernames.
>
> --[[smcv]]
>
>> If my theory is correct, ikiwiki git master now works around this, and the
>> [[plugins/httpauth]] documentation now recommends a more correct configuration.
>> --[[smcv]]
---