2006-11-20 02:52:18 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# HTTP basic auth plugin.
|
|
|
|
package IkiWiki::Plugin::httpauth;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2006-11-20 02:52:18 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-08-03 22:40:12 +02:00
|
|
|
hook(type => "getsetup", id => "httpauth", call => \&getsetup);
|
2006-11-20 10:40:09 +01:00
|
|
|
hook(type => "auth", id => "httpauth", call => \&auth);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-11-20 02:52:18 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-08-03 22:40:12 +02:00
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 0,
|
|
|
|
},
|
2009-11-10 06:50:59 +01:00
|
|
|
cgiauthurl => {
|
|
|
|
type => "string",
|
2009-11-10 06:53:34 +01:00
|
|
|
example => "http://example.com/wiki/auth/ikiwiki.cgi",
|
2009-11-10 06:50:59 +01:00
|
|
|
description => "url to redirect to when authentication is needed",
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 0,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-08-03 22:40:12 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub auth ($$) {
|
2006-11-20 02:52:18 +01:00
|
|
|
my $cgi=shift;
|
|
|
|
my $session=shift;
|
|
|
|
|
|
|
|
if (defined $cgi->remote_user()) {
|
|
|
|
$session->param("name", $cgi->remote_user());
|
|
|
|
}
|
2009-11-10 06:50:59 +01:00
|
|
|
elsif (defined $config{cgiauthurl}) {
|
|
|
|
IkiWiki::redirect($cgi, $config{cgiauthurl}.'?'.$cgi->query_string());
|
|
|
|
exit;
|
|
|
|
}
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-11-20 02:52:18 +01:00
|
|
|
|
|
|
|
1
|