]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/httpauth.pm
typo
[git.ikiwiki.info.git] / IkiWiki / Plugin / httpauth.pm
1 #!/usr/bin/perl
2 # HTTP basic auth plugin.
3 package IkiWiki::Plugin::httpauth;
5 use warnings;
6 use strict;
7 use IkiWiki 3.00;
9 sub import {
10         hook(type => "getsetup", id => "httpauth", call => \&getsetup);
11         hook(type => "auth", id => "httpauth", call => \&auth);
12 }
14 sub getsetup () {
15         return
16                 plugin => {
17                         safe => 1,
18                         rebuild => 0,
19                 },
20                 cgiauthurl => {
21                         type => "string",
22                         example => "http://example.com/wiki/auth/ikiwiki.cgi",
23                         description => "url to redirect to when authentication is needed",
24                         safe => 1,
25                         rebuild => 0,
26                 },
27 }
29 sub auth ($$) {
30         my $cgi=shift;
31         my $session=shift;
33         if (defined $cgi->remote_user()) {
34                 $session->param("name", $cgi->remote_user());
35         }
36         elsif (defined $config{cgiauthurl}) {
37                 IkiWiki::redirect($cgi, $config{cgiauthurl}.'?'.$cgi->query_string());
38                 exit;
39         }
40 }
42 1