Re: auth basic и неавторизованные пользователи

Dmitriy Lyalyuev dmitriy at lyalyuev.pp.ua
Mon Dec 3 13:33:26 UTC 2012


Нашел решение проблемы примерно так:

location ~ /bin/view/(System|System/.*|Main|Main/.*|Sandbox|Sandbox/.*) {
         error_page 404 502 504 = @foswiki_auth;
    }

    location ~ 
/bin/(attach|edit|manage|rename|save|upload|mail|logon|rest|rdiff|.*auth).* 
{
         error_page 404 502 504 = @foswiki_auth;
    }

    location ~ /bin/.* {
         if ($http_cookie ~* "adminid=yes"){
               set $auth "_auth";
         }
         error_page 404 502 504 = @foswiki$auth;
    }

    location ~ 
(^/pub/Trash|^/lib|^/data|^/locale|^/templates|^/tools|^/work)  { deny 
all; }

    location @foswiki_auth {
         gzip off;
         fastcgi_pass             unix:/var/run/wiki/fcgi.sock;
         fastcgi_split_path_info  ^(/bin/\w+)(.*);
         fastcgi_param            SCRIPT_FILENAME 
/opt/data/wiki$fastcgi_script_name;
         fastcgi_param            PATH_INFO       $fastcgi_path_info;
         fastcgi_param            SCRIPT_NAME $fastcgi_script_name;
         fastcgi_param            AUTH_USER       $remote_user;
         fastcgi_param            REMOTE_USER     $remote_user;
         include fastcgi_params;
         auth_basic               "Enter your WikiName. (First name and 
last name, no space, no dots, capitalized, e.g. JohnSmith). Cancel to 
register if you do not have one.";
         auth_basic_user_file     /opt/data/wiki/data/.htpasswd;
         add_header               Set-Cookie "adminid=yes;path=/";
    }

    location @foswiki {
         gzip off;
         fastcgi_pass             unix:/var/run/wiki/fcgi.sock;
         fastcgi_split_path_info  ^(/bin/\w+)(.*);
         fastcgi_param            SCRIPT_FILENAME 
/opt/data/wiki$fastcgi_script_name;
         fastcgi_param            PATH_INFO       $fastcgi_path_info;
         fastcgi_param            SCRIPT_NAME $fastcgi_script_name;
         fastcgi_param            AUTH_USER       $remote_user;
         fastcgi_param            REMOTE_USER     $remote_user;
         include fastcgi_params;
    }

Лучшего варианта пока не придумывается. Может кто-то подскажет более 
элегантный вариант?



Подробная информация о списке рассылки nginx-ru