rc-httpd: support for http basic authentication, fix cgi support to work with hgweb.cgi
This commit is contained in:
parent
060e69b15a
commit
8ef66ca212
4 changed files with 16 additions and 1 deletions
6
rc/bin/rc-httpd/handlers/authorize
Executable file
6
rc/bin/rc-httpd/handlers/authorize
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/rc
|
||||||
|
if(~ $REMOTE_USER ''){
|
||||||
|
extra_headers=($extra_headers 'WWW-Authenticate: Basic realm="'$"SERVER_NAME'"')
|
||||||
|
error 401
|
||||||
|
exit
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ fn filter_headers{
|
||||||
lines=''
|
lines=''
|
||||||
done=false
|
done=false
|
||||||
while(~ $done false){
|
while(~ $done false){
|
||||||
line=`{read}
|
line=`{getline}
|
||||||
head=`{echo $line | awk '{print tolower($1)}'}
|
head=`{echo $line | awk '{print tolower($1)}'}
|
||||||
if(~ $head status:*){
|
if(~ $head status:*){
|
||||||
tmp=`{echo $line | awk '{$1="" ; print}'}
|
tmp=`{echo $line | awk '{$1="" ; print}'}
|
||||||
|
|
|
@ -19,6 +19,11 @@ fn do_error{
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn 401{
|
||||||
|
do_error '401 Unauthorized' \
|
||||||
|
'The requested path '^$"location^' requires authorization.'
|
||||||
|
}
|
||||||
|
|
||||||
fn 404{
|
fn 404{
|
||||||
do_error '404 Not Found' \
|
do_error '404 Not Found' \
|
||||||
'The requested path '^$"location^' was not found on this server.'
|
'The requested path '^$"location^' was not found on this server.'
|
||||||
|
|
|
@ -54,9 +54,13 @@ while(~ $"done false){
|
||||||
HTTP_USER_AGENT=`{echo $line | sed 's;[^:]+:[ ]+;;'}
|
HTTP_USER_AGENT=`{echo $line | sed 's;[^:]+:[ ]+;;'}
|
||||||
case content-length:
|
case content-length:
|
||||||
CONTENT_LENGTH=$line(2)
|
CONTENT_LENGTH=$line(2)
|
||||||
|
case content-type:
|
||||||
|
CONTENT_TYPE=$line(2)
|
||||||
case cookie:
|
case cookie:
|
||||||
cookie=`{echo $line | sed 's;^[^:]+:[ ]*;;'}
|
cookie=`{echo $line | sed 's;^[^:]+:[ ]*;;'}
|
||||||
HTTP_COOKIE=$"HTTP_COOKIE^$"cookie^'; '
|
HTTP_COOKIE=$"HTTP_COOKIE^$"cookie^'; '
|
||||||
|
case authorization:
|
||||||
|
REMOTE_USER=`{auth/httpauth $line(3)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(~ $REQUEST_URI http://*){
|
if(~ $REQUEST_URI http://*){
|
||||||
|
|
Loading…
Reference in a new issue